UserController.class.php 93 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. use Home\Model\OrderModel;
  16. class UserController extends CommonController {
  17. protected function _initialize(){
  18. parent::_initialize();
  19. }
  20. public function set_default_address()
  21. {
  22. $gpc = I('request.');
  23. $token = $gpc['token'];
  24. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  25. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  26. {
  27. echo json_encode( array('code' => 1) );
  28. die();
  29. }
  30. $member_id = $weprogram_token['member_id'];
  31. $id = $gpc['id'];//I('get.id', 0);
  32. M('ims_lionfish_comshop_address')->where( array('member_id' => $member_id ) )->save( $up_data );
  33. $up_data = array();
  34. $up_data['is_default'] = 1;
  35. M('ims_lionfish_comshop_address')->where( array('address_id' => $id ) )->save( $up_data );
  36. echo json_encode( array('code' => 0) );
  37. die();
  38. }
  39. public function group_orders()
  40. {
  41. $_GPC = I('request.');
  42. $token = $_GPC['token'];
  43. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  44. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  45. {
  46. echo json_encode( array('code' => 1) );
  47. die();
  48. }
  49. $member_id = $weprogram_token['member_id'];
  50. $type = isset($_GPC['type']) ? $_GPC['type']:'0';
  51. $page = isset($_GPC['page']) ? $_GPC['page']:'1';//当前第几页
  52. $pre_page = isset($_GPC['pre_page']) ? $_GPC['pre_page']:'10';//每页数量
  53. $offset = ($page -1) * $pre_page;
  54. $where = ' ';
  55. if($type == 1)
  56. {
  57. $where .= ' and p.state = 0 and p.end_time >'.time();
  58. } else if($type == 2){
  59. $where .= ' and p.state = 1 ';
  60. } else if($type == 3){
  61. $where .= ' and (o.order_status_id != 5 && o.order_status_id != 3) and (p.state = 2 or (p.state =0 and p.end_time <'.time().')) ';
  62. }else if($type == 0){
  63. //$where .= ' and o.order_status_id != 3 ';
  64. }
  65. $sql = "select og.goods_id as goods_id, og.name as name,og.goods_images,g.productprice as orign_price,o.voucher_credit,os.name as status_name,os.order_status_id,og.quantity,og.order_goods_id,p.need_count,p.state,p.is_lottery,p.lottery_state,p.end_time,o.delivery,o.lottery_win,o.total,o.shipping_fare,o.order_id,o.store_id,og.price,po.pin_id,o.order_status_id from ".C('DB_PREFIX')."lionfish_comshop_order as o, ".C('DB_PREFIX')."lionfish_comshop_order_goods as og,
  66. ".C('DB_PREFIX')."lionfish_comshop_pin as p,".C('DB_PREFIX')."lionfish_comshop_goods as g ,".C('DB_PREFIX')."lionfish_comshop_order_status as os ,".C('DB_PREFIX')."lionfish_comshop_pin_order as po
  67. where po.order_id = o.order_id and o.order_status_id = os.order_status_id and o.order_id = og.order_id and og.goods_id = g.id and po.pin_id = p.pin_id
  68. and o.member_id = ".$member_id." {$where} order by o.date_added desc limit {$offset},{$pre_page}";
  69. $list = M()->query($sql); //M()->query($sql);
  70. foreach($list as $key => $val)
  71. {
  72. $val['price'] = round($val['price'],2);
  73. //delivery
  74. if($val['order_status_id'] == 10)
  75. {
  76. $val['status_name'] = '等待退款';
  77. }
  78. else if($val['order_status_id'] == 4 && $val['delivery'] =='pickup')
  79. {
  80. //delivery 6
  81. $val['status_name'] = '待自提';
  82. //已自提
  83. }
  84. else if($val['order_status_id'] == 6 && $val['delivery'] =='pickup')
  85. {
  86. //delivery 6
  87. $val['status_name'] = '已自提';
  88. }else if($val['order_status_id'] == 10)
  89. {
  90. $val['status_name'] = '等待退款';
  91. }else if($val['order_status_id'] == 1 && $val['type'] == 'lottery')
  92. {
  93. //等待开奖
  94. //一等奖
  95. if($val['lottery_win'] == 1)
  96. {
  97. $val['status_name'] = '一等奖';
  98. }else {
  99. $val['status_name'] = '等待开奖';
  100. }
  101. }
  102. $pin_type = $val['state'];
  103. if($pin_type == 0 && $val['end_time'] <= time() )
  104. {
  105. $pin_type = 2;
  106. }
  107. switch($pin_type)
  108. {
  109. case 0:
  110. if($val['order_status_id'] == 2)
  111. {
  112. $val['status_name'] = $val['status_name'];
  113. }else{
  114. $val['status_name'] = '拼团中,'.$val['status_name'];
  115. }
  116. break;
  117. case 1:
  118. //7
  119. if($val['order_status_id'] == 7)
  120. {
  121. $val['status_name'] = '拼团成功,售后已退款';
  122. }else if($val['order_status_id'] == 1)
  123. {
  124. $val['status_name'] = '拼团成功,待发货';
  125. }
  126. else{
  127. $val['status_name'] = '拼团成功,'.$val['status_name'];
  128. }
  129. break;
  130. case 2:
  131. $val['status_name'] = '拼团失败,'.$val['status_name'];
  132. //order_status_id 2
  133. if($val['order_status_id'] == 2)
  134. {
  135. $val['status_name'] = '拼团失败';
  136. }
  137. break;
  138. }
  139. $val['goods_images'] = tomedia( $val['goods_images'] );
  140. $order_option_list = M('lionfish_comshop_order_option')->where( array('order_goods_id' => $val['order_goods_id'] ) )->select();
  141. foreach($order_option_list as $option)
  142. {
  143. $val['option_str'][] = $option['value'];
  144. }
  145. if( !isset($val['option_str']) )
  146. {
  147. $val['option_str'] = '';
  148. }else{
  149. $val['option_str'] = implode(',', $val['option_str']);
  150. }
  151. $store_info = array('s_true_name' =>'','s_logo' => '');
  152. $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
  153. $store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
  154. $store_info['s_logo'] = tomedia($store_info['s_logo']);
  155. //$val['store_info'] = $store_info;
  156. //order_id pin_id
  157. $first_tuan = M('lionfish_comshop_pin_order')->where( array('pin_id' => $val['pin_id'] ) )->order('id asc')->find();
  158. if( $first_tuan['order_id'] == $val['order_id'] )
  159. {
  160. $val['me_is_head'] = 1;
  161. }else{
  162. $val['me_is_head'] = 0;
  163. }
  164. $val['price'] = round($val['price'],2);
  165. if($val['delivery'] == 'pickup')
  166. {
  167. $val['total'] = round($val['total'],2) - round($val['voucher_credit'],2);
  168. }else{
  169. $val['total'] = round($val['total'],2)+round($val['shipping_fare'],2) - round($val['voucher_credit'],2);
  170. }
  171. if($val['shipping_fare']<=0.001 || $val['delivery'] == 'pickup')
  172. {
  173. $val['shipping_fare'] = '免运费';
  174. }else{
  175. $val['shipping_fare'] = '运费:'.$val['shipping_fare'];
  176. }
  177. $val['orign_price'] = round($val['orign_price'],2);
  178. if($val['state'] == 0 && $val['end_time'] < time())
  179. {
  180. $val['state'] = 2;
  181. }
  182. $list[$key] = $val;
  183. }
  184. $need_data = array();
  185. $need_data['code'] = 1;
  186. if( !empty($list) )
  187. {
  188. $need_data['code'] = 0;
  189. $need_data['data'] = $list;
  190. }
  191. echo json_encode($need_data);
  192. die();
  193. }
  194. public function sub_user_shop()
  195. {
  196. $gpc = I('request.');
  197. $token = $gpc['token'];
  198. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  199. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  200. {
  201. echo json_encode( array('code' => 1) );
  202. die();
  203. }
  204. $member_id = $weprogram_token['member_id'];
  205. $id = $gpc['id'];
  206. $data = array();
  207. $data['member_id'] = $member_id;
  208. $data['shop_name'] = $gpc['head_name'];
  209. $data['shop_mobile'] = $gpc['head_mobile'];
  210. $data['imgGroup'] = $gpc['imgGroup'];
  211. $data['otherImgGroup'] = $gpc['otherImgGroup'];
  212. $data['state'] = 0;
  213. $data['addtime'] = time();
  214. //------
  215. $has_shopinfo = M('lionfish_comshop_member_shopinfo')->where( array('member_id' => $member_id ) )->find();
  216. if( !empty($has_shopinfo) )
  217. {
  218. echo json_encode( array('code' => 1, 'msg' => '您已经申请过了') );
  219. die();
  220. }else{
  221. M('lionfish_comshop_member_shopinfo')->add($data);
  222. echo json_encode( array('code' => 0) );
  223. die();
  224. }
  225. }
  226. public function user_index_shareqrcode()
  227. {
  228. $_GPC = I('request.');
  229. $token = $_GPC['token'];
  230. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  231. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  232. {
  233. $member_id = 0;
  234. }else{
  235. $member_id = $weprogram_token['member_id'];
  236. }
  237. $community_id = $_GPC['community_id'];
  238. //community_id: undefined
  239. $community_config_qrcode_json = D('Home/Front')->get_config_by_name('community_config_qrcode_'.$community_id );
  240. $community_config_qrcode_arr = unserialize($community_config_qrcode_json);
  241. $load_new = false;
  242. if( empty($community_config_qrcode_arr) )
  243. {
  244. $load_new = true;
  245. }else {
  246. if( $community_config_qrcode_arr['endtime'] < time() )
  247. {
  248. $load_new = true;
  249. }
  250. }
  251. //member_id
  252. $is_login_showprice = D('Home/Front')->get_config_by_name('is_login_showprice');
  253. if( !empty($is_login_showprice) && $is_login_showprice == 1 )
  254. {
  255. $load_new = true;
  256. }
  257. if( $load_new)
  258. {
  259. $goods_model = D('Home/Pingoods');
  260. $community_info = M('lionfish_community_head')->where( array('id' => $community_id) )->find();
  261. $tuanz_member_id = $community_info['member_id'];
  262. if(empty($member_id))
  263. {
  264. $member_id = $tuanz_member_id;
  265. }
  266. $qrcode_image = $goods_model->_get_index_wxqrcode($member_id,$community_id);
  267. $member_info = M('lionfish_comshop_member')->field('avatar,username,wepro_qrcode')
  268. ->where( array('member_id' => $tuanz_member_id) )->find();
  269. //fff562 get_weindex_share_image
  270. $avatar = $goods_model->get_user_avatar($member_info['avatar'], $tuanz_member_id,2);
  271. //is_hyaline Bool false
  272. $result = $goods_model->get_weindex_share_image($community_id,$qrcode_image,$avatar , $member_id);
  273. $data = array();
  274. $data['image_path'] = $result['full_path'];
  275. $ed_time = time() + 1800;
  276. $js_arr = array('endtime' => $ed_time,'image_path' => $data['image_path'] );
  277. $cd_key = 'community_config_qrcode_'.$community_id;
  278. D('Seller/Config')->update( array( $cd_key => serialize($js_arr) ) );
  279. }else{
  280. $data = array();
  281. $data['image_path'] = $community_config_qrcode_arr['image_path'];
  282. }
  283. $shop_domain = D('Home/Front')->get_config_by_name('shop_domain');
  284. $data['image_path'] = $shop_domain.'/'.$data['image_path'];
  285. $result = array('code' => 0, 'image_path' => $data['image_path'] );
  286. echo json_encode($result);
  287. die();
  288. }
  289. public function myvoucherlist()
  290. {
  291. $_GPC = I('request.');
  292. $type = isset($_GPC['type']) && !empty($_GPC['type']) ? $_GPC['type'] : 1;
  293. $page = isset($_GPC['page']) && !empty($_GPC['page']) ? $_GPC['page'] : 1;
  294. $pre_page = 20;
  295. $offset = ($page -1) * $pre_page;
  296. $token = $_GPC['token'];
  297. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  298. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  299. {
  300. echo json_encode( array('code' => 1) );
  301. die();
  302. }
  303. $member_id = $weprogram_token['member_id'];
  304. if( empty($member_id) )
  305. {
  306. $result['code'] = 3;
  307. $result['msg'] = '登录失效';
  308. echo json_encode($result);
  309. die();
  310. }
  311. $condition = "user_id=".$member_id;
  312. if($type == 1)
  313. {
  314. //未使用
  315. $condition .= " and consume= 'N' and end_time> ".time();
  316. } else if($type == 2){
  317. //已使用
  318. $condition .= " and (consume= 'Y' or end_time< ".time().")";
  319. }
  320. $list = M('lionfish_comshop_coupon_list')->where($condition)->order('add_time desc')->limit($offset,$pre_page)->select();
  321. $now_time = time();
  322. $category_list = M('lionfish_comshop_coupon_category')->field('id,name,status')->where( array('merchid' => 0) )->order('id desc')->select();
  323. $category = array();
  324. foreach($category_list as $val)
  325. {
  326. $category[$val['id']] = $val;
  327. }
  328. $k = 0;
  329. $result_list = array();
  330. foreach($list as $key => $val)
  331. {
  332. $couponid = $val['voucher_id'];
  333. $coupon = M('lionfish_comshop_coupon')->field('catid')->where( array('id' => $couponid) )->find();
  334. $val['tag'] = $category[$coupon['catid']]['name'];
  335. $store_info = array('s_true_name' =>'','s_logo' => '');
  336. $store_info['s_true_name'] = D('Home/Front')->get_config_by_name('shoname');
  337. $store_info['s_logo'] = D('Home/Front')->get_config_by_name('shoplogo');
  338. if( !empty($store_info['s_logo']))
  339. {
  340. $store_info['s_logo'] = tomedia($store_info['s_logo']);
  341. }else{
  342. $store_info['s_logo'] = '';
  343. }
  344. $val['store_name'] = $store_info['s_true_name'];
  345. $val['s_logo'] = $store_info['s_logo'];
  346. //now_time
  347. $val['is_over'] = 0;
  348. $val['is_use'] = 0;
  349. if($val['end_time'] < $now_time)
  350. {
  351. $val['is_over'] = 1;
  352. }
  353. if($val['consume'] == 'Y')
  354. {
  355. $val['is_use'] = 1;
  356. }
  357. $val['begin_time'] = date('Y.m.d H:i:s', $val['begin_time']);
  358. $val['end_time'] = date('Y.m.d H:i:s', $val['end_time']);
  359. $result_list[$k] = $val;
  360. $k++;
  361. }
  362. if( empty($result_list) )
  363. {
  364. echo json_encode( array('code' =>1) );
  365. }else {
  366. echo json_encode( array('code' =>0, 'list' => $result_list) );
  367. }
  368. }
  369. public function refunddetail()
  370. {
  371. $gpc = I('request.');
  372. $token = $gpc['token'];
  373. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  374. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  375. {
  376. echo json_encode( array('code' => 1) );
  377. die();
  378. }
  379. $member_id = $weprogram_token['member_id'];
  380. if( empty($member_id) )
  381. {
  382. $result['code'] = 0;
  383. $result['msg'] = '登录失效';
  384. echo json_encode($result);
  385. die();
  386. }
  387. $ref_id = $gpc['ref_id'];
  388. $order_refund = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
  389. $order_id = $order_refund['order_id'];
  390. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id,'member_id' => $member_id) )->find();
  391. if(empty($order_info) )
  392. {
  393. $result['code'] = 0;
  394. $result['msg'] = '无此订单';
  395. echo json_encode($result);
  396. die();
  397. }
  398. if($order_refund['order_goods_id'] > 0)
  399. {
  400. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_refund['order_goods_id'] ,'order_id' =>$order_id ) )->find();
  401. }else{
  402. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id) )->find();
  403. }
  404. if($order_refund['order_goods_id'] > 0)
  405. {
  406. $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('type' => 2, 'order_goods_id' => $order_refund['order_goods_id'], 'order_id' =>$order_id ) )->order('addtime asc')->find();
  407. }else{
  408. $order_refund_history = M('lionfish_comshop_order_refund_history')->where( array('type' => 2,'order_id' => $order_id) )->order('addtime asc')->find();
  409. }
  410. $refund_reason = array(
  411. '97' =>'商品有质量问题',
  412. '98' =>'没有收到货',
  413. '99' =>'商品少发漏发发错',
  414. '100' =>'商品与描述不一致',
  415. '101' =>'收到商品时有划痕或破损',
  416. '102' =>'质疑假货',
  417. '111' =>'其他',
  418. );
  419. $order_refund['ref_type'] = $order_refund['ref_type'] ==1 ? '仅退款': '退款退货';
  420. $refund_state = array(
  421. 0 => '申请中',
  422. 1 => '商家拒绝',
  423. 2 => '平台介入',
  424. 3 => '退款成功',
  425. 4 => '退款失败',
  426. 5 => '撤销申请',
  427. );
  428. $order_refund['state'] = $refund_state[$order_refund['state']];
  429. $order_refund['addtime'] = date('Y-m-d H:i:s', $order_refund['addtime']);
  430. $order_refund_image = M('lionfish_comshop_order_refund_image')->where( array('ref_id' => $order_refund['ref_id']) )->select();
  431. $url = D('Home/Front')->get_config_by_name('shop_domain');
  432. $refund_images = array();
  433. if(!empty($order_refund_image))
  434. {
  435. foreach($order_refund_image as $refund_image)
  436. {
  437. $refund_image['thumb_image'] = $refund_image['image'] ;
  438. $refund_images[] = $refund_image;
  439. }
  440. }
  441. if($order_refund['order_goods_id'] > 0)
  442. {
  443. $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_goods_id' => $order_refund['order_goods_id'],'order_id' => $order_id) )->order('addtime asc')->select();
  444. }else{
  445. $order_refund_historylist = M('lionfish_comshop_order_refund_history')->where( array('order_id' => $order_id) )->order('addtime asc')->select();
  446. }
  447. //ims_
  448. //.type ==3
  449. $pingtai_deal = 0;
  450. foreach($order_refund_historylist as $key => $val)
  451. {
  452. if($val['type'] ==3)
  453. {
  454. $pingtai_deal = 1;
  455. }
  456. $order_refund_history_image = M('lionfish_comshop_order_refund_history_image')->where( array('orh_id' => $val['id']) )->select();
  457. if(!empty($order_refund_history_image))
  458. {
  459. foreach($order_refund_history_image as $kk => $vv)
  460. {
  461. $vv['thumb_image'] = $url. resize($vv['image'], 200,200) ;
  462. $order_refund_history_image[$kk] = $vv;
  463. }
  464. }
  465. $val['order_refund_history_image'] = $order_refund_history_image;
  466. $val['addtime'] = date('Y-m-d H:i:s', $val['addtime']);
  467. $order_refund_historylist[$key] = $val;
  468. }
  469. echo json_encode( array('code' => 1,'pingtai_deal' => $pingtai_deal,'order_refund' =>$order_refund, 'order_id' => $order_id ,'order_refund_history' => $order_refund_history,'order_refund_historylist' => $order_refund_historylist, 'refund_images' => $refund_images,'order_goods' => $order_goods ,'order_info' => $order_info) );
  470. die();
  471. }
  472. public function cancel_refund()
  473. {
  474. $gpc = I('request.');
  475. $token = $gpc['token'];
  476. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  477. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  478. {
  479. echo json_encode( array('code' => 1) );
  480. die();
  481. }
  482. $member_id = $weprogram_token['member_id'];
  483. $ref_id = $gpc['ref_id'];
  484. $order_refund = M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->find();
  485. $order_id = $order_refund['order_id'];
  486. //$order_id = $gpc['order_id'];
  487. if( empty($member_id) )
  488. {
  489. $result['code'] = 0;
  490. $result['msg'] = '登录失效';
  491. echo json_encode($result);
  492. die();
  493. }
  494. $result = array('code' => 0);
  495. $order_info = M('lionfish_comshop_order')->where( array('member_id' => $member_id, 'order_id' => $order_id) )->find();
  496. if(empty($order_info) )
  497. {
  498. $result['msg'] = '非法操作';
  499. echo json_encode($result);
  500. die();
  501. }
  502. M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id) )->save( array('state' => 5) );
  503. //ims_
  504. $order_history = array();
  505. $order_history['order_id'] = $order_id;
  506. $order_history['order_goods_id'] = $order_refund['order_goods_id'];
  507. $order_history['order_status_id'] = 4;
  508. $order_history['notify'] = 0;
  509. $order_history['comment'] = '用户撤销退款';
  510. $order_history['date_added']=time();
  511. M('lionfish_comshop_order_history')->add($order_history);
  512. //ims_lionfish_comshop_order_goods
  513. if($order_refund['order_goods_id'] > 0)
  514. {
  515. M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_refund['order_goods_id']) )->save( array('is_refund_state' => 0) );
  516. if($order_info['order_status_id'] == 12)
  517. {
  518. //检测 last_refund_order_status_id
  519. $order_gd_info = M('lionfish_comshop_order_goods')->where( array('is_refund_state' => 1, 'order_id' => $order_id ) )->find();
  520. if( empty($order_gd_info) )
  521. {
  522. if($order_info['last_refund_order_status_id'] > 0)
  523. {
  524. M('lionfish_comshop_order')->where( array('member_id' => $member_id, 'order_id' => $order_id) )->save( array('order_status_id' => $order_info['last_refund_order_status_id'] ) );
  525. }else{
  526. M('lionfish_comshop_order')->where( array('member_id' => $member_id, 'order_id' => $order_id) )->save( array('order_status_id' => 4) );
  527. }
  528. }
  529. }
  530. }else{
  531. if($order_info['last_refund_order_status_id'] > 0)
  532. {
  533. M('lionfish_comshop_order')->where( array('member_id' => $member_id, 'order_id' => $order_id) )->save( array('order_status_id' => $order_info['last_refund_order_status_id'] ) );
  534. }else{
  535. M('lionfish_comshop_order')->where( array('member_id' => $member_id, 'order_id' => $order_id) )->save( array('order_status_id' => 4) );
  536. }
  537. }
  538. $result['code'] = 1;
  539. echo json_encode($result);
  540. die();
  541. }
  542. public function refund_sub()
  543. {
  544. $gpc = I('request.');
  545. $token = $gpc['token'];
  546. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  547. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  548. {
  549. echo json_encode( array('code' => 1) );
  550. die();
  551. }
  552. $member_id = $weprogram_token['member_id'];
  553. if( empty($member_id) )
  554. {
  555. $result['code'] = 0;
  556. $result['msg'] = '登录失效';
  557. echo json_encode($result);
  558. die();
  559. }
  560. $data = array();
  561. $data['order_id'] = $gpc['order_id'];
  562. $data['complaint_type'] = $gpc['complaint_type'];
  563. $data['complaint_images'] = $gpc['complaint_images'];
  564. $data['complaint_desc'] = $gpc['complaint_desc'];
  565. $data['complaint_mobile'] = $gpc['complaint_mobile'];
  566. $data['complaint_reason'] = $gpc['complaint_reason'];
  567. $data['complaint_money'] = $gpc['complaint_money'];
  568. if( !empty($data['complaint_images']) )
  569. {
  570. $data['complaint_images'] = explode(',', $data['complaint_images']);
  571. }
  572. $order_id = $data['order_id'];
  573. $order_goods_id = $gpc['order_goods_id'];
  574. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id,'member_id' => $member_id) )->find();
  575. if(empty($order_info) )
  576. {
  577. $result['code'] = 0;
  578. $result['msg'] = '没有此订单';
  579. echo json_encode($result);
  580. die();
  581. }
  582. $result = array('code' => 0);
  583. $refdata = array();
  584. $refdata['order_id'] = intval($data['order_id']);
  585. $refdata['ref_type'] = intval($data['complaint_type']);
  586. $refdata['ref_money'] = floatval($data['complaint_money']);
  587. $refdata['ref_member_id'] = $member_id;
  588. $refdata['ref_name'] = htmlspecialchars($data['complaint_reason']);
  589. $refdata['ref_mobile'] = htmlspecialchars($data['complaint_mobile']);
  590. $refdata['ref_description'] = htmlspecialchars($data['complaint_desc']);
  591. $refdata['state'] = 0;
  592. $refdata['addtime'] = time();
  593. $order_info['total'] = round($order_info['total'],2)< 0.01 ? '0.00':round($order_info['total']+$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money'],2) ;
  594. if( !empty($order_goods_id) && $order_goods_id > 0 )
  595. {
  596. //ims_lionfish_comshop_order_goods
  597. $order_goods_info = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->find();
  598. $tp_total = round($order_goods_info['total'],2)< 0.01 ? '0.00':round($order_goods_info['total']+$order_goods_info['shipping_fare']-$order_goods_info['voucher_credit']-$order_goods_info['score_for_money']-$order_goods_info['fullreduction_money'],2) ;
  599. $order_info['total'] = $tp_total;
  600. }else{
  601. $tp_total = 0;
  602. $order_goods_list = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'is_refund_state' => 0) )->select();
  603. foreach($order_goods_list as $order_goods_info)
  604. {
  605. $tp_total += round($order_goods_info['total'],2)< 0.01 ? '0.00':round($order_goods_info['total']+$order_goods_info['shipping_fare']-$order_goods_info['voucher_credit']-$order_goods_info['score_for_money']-$order_goods_info['fullreduction_money'],2) ;
  606. }
  607. $order_info['total'] = $tp_total;
  608. }
  609. if($order_info['total'] < 0)
  610. {
  611. $order_info['total'] = '0.00';
  612. }
  613. if($refdata['ref_money'] > $order_info['total'])
  614. {
  615. $result['msg'] = '退款金额不能大于订单总额';
  616. echo json_encode($result);
  617. die();
  618. }
  619. if(!empty($data['ref_id']))
  620. {
  621. $ref_id = intval($data['ref_id']);
  622. unset($refdata['order_id']);
  623. unset($refdata['ref_member_id']);
  624. unset($refdata['addtime']);
  625. M('lionfish_comshop_order_refund')->where( array('ref_id' => $ref_id ) )->save( $refdata );
  626. $order_history = array();
  627. $order_history['order_id'] = $order_id;
  628. $order_history['order_status_id'] = $order_info['order_status_id'];
  629. $order_history['notify'] = 0;
  630. $order_history['comment'] = '用户修改退款资料';
  631. $order_history['date_added']=time();
  632. // M('lionfish_comshop_order_history')->add($order_history);
  633. $order_refund_history = array();
  634. $order_refund_history['order_id'] = $order_id;
  635. $order_refund_history['order_goods_id'] = $order_goods_id;
  636. $order_refund_history['message'] = $refdata['ref_description'];
  637. $order_refund_history['type'] = 1;
  638. $order_refund_history['addtime'] = time();
  639. $orh_id = M('lionfish_comshop_order_refund_history')->add($order_refund_history);
  640. if(!empty($data['complaint_images']))
  641. {
  642. foreach($data['complaint_images'] as $complaint_images)
  643. {
  644. $img_data = array();
  645. $img_data['orh_id'] = $orh_id;
  646. $img_data['uniacid'] = $_W['uniacid'];
  647. $img_data['image'] = htmlspecialchars($complaint_images);
  648. $img_data['addtime'] = time();
  649. M('lionfish_comshop_order_refund_history_image')->add($img_data);
  650. }
  651. }
  652. }else {
  653. $refdata['order_goods_id'] = $order_goods_id;
  654. $ref_id = M('lionfish_comshop_order_refund')->add($refdata);
  655. $can_refund_order = true;
  656. if( !empty($order_goods_id) && $order_goods_id > 0 )
  657. {
  658. M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id ) )->save( array('is_refund_state' => 1) );
  659. //判断是否全部都退款了
  660. $gdall = M('lionfish_comshop_order_goods')->field('is_refund_state')->where( array('order_id' =>$order_id ) )->select();
  661. foreach( $gdall as $vv )
  662. {
  663. if( $vv['is_refund_state'] == 0 )
  664. {
  665. $can_refund_order = false;
  666. break;
  667. }
  668. }
  669. }else{
  670. M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->save( array('is_refund_state' => 1) );
  671. }
  672. /**
  673. 判断是否所有订单都在退款中
  674. **/
  675. if($can_refund_order)
  676. {
  677. $up_order = array();
  678. $up_order['order_status_id'] = 12;
  679. $up_order['last_refund_order_status_id'] = $order_info['order_status_id'];
  680. M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->save( $up_order );
  681. $order_history = array();
  682. $order_history['order_id'] = $order_id;
  683. $order_history['order_goods_id'] = $order_goods_id;
  684. $order_history['order_status_id'] = 12;
  685. $order_history['notify'] = 0;
  686. $order_history['comment'] = '用户前台申请退款中';
  687. $order_history['date_added']=time();
  688. M('lionfish_comshop_order_history')->add($order_history);
  689. }else{
  690. //部分商品退款
  691. $order_history = array();
  692. $order_history['order_id'] = $order_id;
  693. $order_history['order_goods_id'] = $order_goods_id;
  694. $order_history['order_status_id'] = 12;
  695. $order_history['notify'] = 0;
  696. $order_history['comment'] = '用户申请部分商品退款';
  697. $order_history['date_added']=time();
  698. M('lionfish_comshop_order_history')->add($order_history);
  699. }
  700. if(!empty($data['complaint_images']))
  701. {
  702. //complaint_images
  703. foreach($data['complaint_images'] as $complaint_images)
  704. {
  705. $img_data = array();
  706. $img_data['ref_id'] = $ref_id;
  707. $img_data['uniacid'] = $_W['uniacid'];
  708. $img_data['image'] = htmlspecialchars($complaint_images);
  709. $img_data['addtime'] = time();
  710. M('lionfish_comshop_order_refund_image')->add($img_data);
  711. }
  712. }
  713. }
  714. $result['code'] = 1;
  715. echo json_encode($result);
  716. die();
  717. }
  718. public function goods_express()//
  719. {
  720. $_GPC = I('request.');
  721. $token = $_GPC['token'];
  722. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  723. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  724. {
  725. echo json_encode( array('code' => 1) );
  726. die();
  727. }
  728. $member_id = $weprogram_token['member_id'];
  729. $order_id = $_GPC['order_id'];// I('get.order_id',0);
  730. if( empty($member_id) )
  731. {
  732. $result['code'] = 2;
  733. $result['msg'] = '登录失效';
  734. echo json_encode($result);
  735. die();
  736. }
  737. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->find();
  738. $now_time = time();
  739. if($now_time - $order_info['shipping_cha_time'] >= 43200)
  740. {
  741. //即时查询接口
  742. $seller_express = M('lionfish_comshop_express')->where( array('id' => $order_info['shipping_method'] ) )->find();
  743. if(!empty($seller_express['simplecode']))
  744. {
  745. //887406591556327434 YTO
  746. //TODO...
  747. $ebuss_info = D('Home/Front')->get_config_by_name('kdniao_id');
  748. $exappkey = D('Home/Front')->get_config_by_name('kdniao_api_key');
  749. $req_url = "http://api.kdniao.com/Ebusiness/EbusinessOrderHandle.aspx";
  750. $requestData= "{'OrderCode':'".$order_id."','ShipperCode':'".$seller_express['simplecode']."','LogisticCode':'". $order_info['shipping_no']."'}";
  751. $kdniao_freestatus = D('Home/Front')->get_config_by_name('kdniao_freestatus');
  752. $customerName = $order_info['shipping_tel'];
  753. $customerName = substr($customerName,7);
  754. $datas = array(
  755. 'EBusinessID' => $ebuss_info,
  756. 'RequestType' => '1002',
  757. 'RequestData' => urlencode($requestData) ,
  758. 'DataType' => '2',
  759. 'CustomerName'=>$customerName
  760. );
  761. if( isset($kdniao_freestatus) && $kdniao_freestatus ==1 )
  762. {
  763. $datas['RequestType'] = '8001';
  764. }
  765. $datas['DataSign'] = $this->encrypt($requestData, $exappkey);
  766. $result=$this->sendPost($req_url, $datas);
  767. $result = json_decode($result);
  768. // var_dump($result);
  769. //根据公司业务处理返回的信息......
  770. //Traces
  771. if(!empty($result->Traces))
  772. {
  773. $order_info['shipping_traces'] = serialize($result->Traces);
  774. $up_data = array('shipping_cha_time' => time(), 'shipping_traces' => $order_info['shipping_traces']);
  775. M('lionfish_comshop_order')->where( array('order_id' => $order_id ) )->save( $up_data );
  776. }
  777. }
  778. }
  779. //ims_
  780. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id ) )->find();
  781. $goods_info = array();
  782. $goods_info = D('Home/Pingoods')->get_goods_images($order_goods['goods_id']);
  783. $goods_info['image'] = tomedia($goods_info['image']);
  784. $seller_express = M('lionfish_comshop_express')->where( array('id' => $order_info['shipping_method'] ) )->find();
  785. $order_info['shipping_traces'] = unserialize($order_info['shipping_traces']) ;
  786. echo json_encode( array('code' => 0, 'seller_express' => $seller_express, 'goods_info' => $goods_info, 'order_info' => $order_info) );
  787. die();
  788. }
  789. public function get_order_money()
  790. {
  791. $gpc = I('request.');
  792. $token = $gpc['token'];
  793. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  794. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  795. {
  796. echo json_encode( array('code' => 1) );
  797. die();
  798. }
  799. $member_id = $weprogram_token['member_id'];
  800. if( empty($member_id) )
  801. {
  802. $result['code'] = 0;
  803. $result['msg'] = '登录失效';
  804. echo json_encode($result);
  805. die();
  806. }
  807. $order_id = $gpc['order_id'];
  808. $order_goods_id = $gpc['order_goods_id'];
  809. //total lionfish_comshop_order
  810. $total = 0;
  811. if( !empty($order_goods_id) && $order_goods_id > 0 )
  812. {
  813. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id , 'member_id' => $member_id ) )->find();
  814. $order_goods_all = M('lionfish_comshop_order_goods')->where( array('order_goods_id' => $order_goods_id,'order_id' => $order_id) )->select();
  815. foreach($order_goods_all as $val )
  816. {
  817. $total += $val['total'] + $val['shipping_fare']- $val['voucher_credit']- $val['fullreduction_money'] - $val['score_for_money'];
  818. }
  819. echo json_encode( array('code' =>1, 'total' => $total, 'order_status_id'=>$order_info['order_status_id']) );
  820. die();
  821. }else{
  822. $order_info = M('lionfish_comshop_order')->where( array('order_id' => $order_id,'member_id' =>$member_id ) )->find();
  823. $order_goods_all = M('lionfish_comshop_order_goods')->where( array('order_id' => $order_id, 'is_refund_state' => 0) )->select();
  824. foreach($order_goods_all as $val )
  825. {
  826. $total += $val['total'] + $val['shipping_fare']- $val['voucher_credit']- $val['fullreduction_money'] - $val['score_for_money'];
  827. }
  828. //$order_info['total'] = $order_info['total']+$order_info['shipping_fare']-$order_info['voucher_credit']-$order_info['fullreduction_money']- $order_info['score_for_money'];
  829. //还要判断依据退款的
  830. if($total < 0){
  831. $total = 0;
  832. }
  833. $total = round($total, 2);
  834. echo json_encode( array('code' =>1, 'total' => $total, 'order_status_id'=>$order_info['order_status_id']) );
  835. die();
  836. }
  837. }
  838. function encrypt($data, $appkey) {
  839. return urlencode(base64_encode(md5($data.$appkey)));
  840. }
  841. function sendPost($url, $datas) {
  842. $temps = array();
  843. foreach ($datas as $key => $value) {
  844. $temps[] = sprintf('%s=%s', $key, $value);
  845. }
  846. $post_data = implode('&', $temps);
  847. $url_info = parse_url($url);
  848. if(empty($url_info['port']))
  849. {
  850. $url_info['port']=80;
  851. }
  852. $httpheader = "POST " . $url_info['path'] . " HTTP/1.0\r\n";
  853. $httpheader.= "Host:" . $url_info['host'] . "\r\n";
  854. $httpheader.= "Content-Type:application/x-www-form-urlencoded\r\n";
  855. $httpheader.= "Content-Length:" . strlen($post_data) . "\r\n";
  856. $httpheader.= "Connection:close\r\n\r\n";
  857. $httpheader.= $post_data;
  858. $fd = fsockopen($url_info['host'], $url_info['port']);
  859. fwrite($fd, $httpheader);
  860. $gets = "";
  861. $headerFlag = true;
  862. while (!feof($fd)) {
  863. if (($header = @fgets($fd)) && ($header == "\r\n" || $header == "\n")) {
  864. break;
  865. }
  866. }
  867. while (!feof($fd)) {
  868. $gets.= fread($fd, 128);
  869. }
  870. fclose($fd);
  871. return $gets;
  872. }
  873. //TODO.....next
  874. public function getaddress()
  875. {
  876. $gpc = I('request.');
  877. $token = $gpc['token'];
  878. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  879. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  880. {
  881. echo json_encode( array('code' => 1) );
  882. die();
  883. }
  884. $member_id = $weprogram_token['member_id'];
  885. $address_list = M('lionfish_comshop_address')->where( array('member_id' => $member_id) )->order('is_default desc , address_id desc')->select();
  886. foreach( $address_list as $key => $val )
  887. {
  888. //province_id city_id country_id
  889. $province_info = M('lionfish_comshop_area')->field('name')->where( array('id' => $val['province_id']) )->find();
  890. $city_info = M('lionfish_comshop_area')->field('name')->where( array('id' => $val['city_id']))->find();
  891. $country_info = M('lionfish_comshop_area')->field('name')->where( array('id' => $val['country_id'] ) )->find();
  892. $val['province_name'] = $province_info['name'];
  893. $val['city_name'] = $city_info['name'];
  894. $val['country_name'] = $country_info['name'];
  895. $address_list[$key] = $val;
  896. }
  897. if( !empty($address_list) )
  898. {
  899. echo json_encode( array('code' => 0, 'list' => $address_list) );
  900. die();
  901. }else{
  902. echo json_encode( array('code' => 1) );
  903. die();
  904. }
  905. }
  906. /**
  907. 收集订阅消息
  908. **/
  909. public function collect_subscriptmsg()
  910. {
  911. $_GPC = I('request.');
  912. $token = $_GPC['token'];
  913. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  914. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  915. {
  916. echo json_encode( array('code' => 1) );
  917. die();
  918. }
  919. $member_id = $weprogram_token['member_id'];
  920. //'pay_order','send_order','hexiao_success','apply_community','open_tuan','take_tuan','pin_tuansuccess','apply_tixian'
  921. $type_str = $_GPC['type'];
  922. $type_arr = explode(',', $type_str);
  923. foreach( $type_arr as $type )
  924. {
  925. $info = M('lionfish_comshop_subscribe')->where( array('member_id' => $member_id, 'type' => $type ) )->find();
  926. if( !empty($info) && false )
  927. {
  928. continue;
  929. }
  930. $template_id = "";
  931. switch( $type )
  932. {
  933. case 'pay_order':
  934. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_pay_order');
  935. break;
  936. case 'send_order':
  937. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_send_order');
  938. break;
  939. case 'hexiao_success':
  940. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_hexiao_success');
  941. break;
  942. case 'apply_community':
  943. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_apply_community');
  944. break;
  945. case 'open_tuan':
  946. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_open_tuan');
  947. break;
  948. case 'take_tuan':
  949. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_take_tuan');
  950. break;
  951. case 'pin_tuansuccess':
  952. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_pin_tuansuccess');
  953. break;
  954. case 'apply_tixian':
  955. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_apply_tixian');
  956. break;
  957. case 'presale_ordercan_continuepay':
  958. $template_id = D('Home/Front')->get_config_by_name('weprogram_subtemplate_presale_ordercan_continuepay');
  959. break;
  960. }
  961. if( empty($template_id) )
  962. {
  963. continue;
  964. }
  965. $ins_data = array();
  966. $ins_data['uniacid'] = 0;
  967. $ins_data['member_id'] = $member_id;
  968. $ins_data['template_id'] = $template_id;
  969. $ins_data['type'] = $type;
  970. $ins_data['addtime'] = time();
  971. M('lionfish_comshop_subscribe')->add( $ins_data );
  972. }
  973. echo json_encode( array('code' => 0) );
  974. die();
  975. }
  976. public function order_comment()
  977. {
  978. $gpc = I('request.');
  979. $token = $gpc['token'];
  980. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  981. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  982. {
  983. echo json_encode( array('code' => 1) );
  984. die();
  985. }
  986. $member_id = $weprogram_token['member_id'];
  987. $order_id = $gpc['order_id'];
  988. $goods_id = $gpc['goods_id'];
  989. if( empty($member_id) )
  990. {
  991. $result['code'] = 3;
  992. $result['msg'] = '登录失效';
  993. echo json_encode($result);
  994. die();
  995. }
  996. //ims_ lionfish_comshop_order_goods ims_lionfish_comshop_order_goods
  997. $order_goods = M('lionfish_comshop_order_goods')->where( array('order_id' =>$order_id ,'goods_id' => $goods_id) )->find();
  998. $order_option_list =M('lionfish_comshop_order_option')->where( array('order_goods_id' => $order_goods['order_goods_id']) )->select();
  999. $order_goods['goods_images'] = tomedia($order_goods['goods_images']);
  1000. $goods_filed = M('lionfish_comshop_goods')->field('productprice')->where( array('id' => $order_goods['goods_id']) )->find();
  1001. $order_goods['orign_price'] = $goods_filed['productprice'];
  1002. foreach($order_option_list as $option)
  1003. {
  1004. $order_goods['option_str'][] = $option['value'];
  1005. }
  1006. if( !isset($order_goods['option_str']) )
  1007. {
  1008. $order_goods['option_str'] = '';
  1009. }else{
  1010. $order_goods['option_str'] = implode(',', $order_goods['option_str']);
  1011. }
  1012. $order_goods['price'] = round($order_goods['price'],2);
  1013. $order_goods['orign_price'] = round($order_goods['orign_price'],2);
  1014. $image_info = D('Home/Pingoods')->get_goods_images( $order_goods['goods_id'] );
  1015. // M('goods')->field('image')->where( array('goods_id' => ) )->find();
  1016. $goods_image = tomedia($image_info['image']);
  1017. $open_comment_gift = D('Home/Front')->get_config_by_name('open_comment_gift');
  1018. $open_comment_gift = !empty($open_comment_gift) ? $open_comment_gift : 0;
  1019. //打到上限关闭
  1020. $commentresult = D('Seller/Order')->check_comment_gift_score($member_id);
  1021. if(!$commentresult['is_comment_gift']){
  1022. $open_comment_gift = 0;
  1023. }
  1024. $comment_gift_publish = D('Home/Front')->get_config_by_name('comment_gift_publish');
  1025. $comment_gift_publish = htmlspecialchars_decode($comment_gift_publish);
  1026. echo json_encode( array('code' => 0 ,'order_goods' =>$order_goods, 'goods_image' => $goods_image,'goods_id' =>$order_goods['goods_id']
  1027. ,'open_comment_gift' =>$open_comment_gift,'comment_gift_publish' =>$comment_gift_publish
  1028. ) );
  1029. die();
  1030. }
  1031. public function sub_comment()
  1032. {
  1033. $gpc = I('request.');
  1034. $token = $gpc['token'];
  1035. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1036. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1037. {
  1038. echo json_encode( array('code' => 1) );
  1039. die();
  1040. }
  1041. $member_id = $weprogram_token['member_id'];
  1042. if( empty($member_id) )
  1043. {
  1044. $result['code'] = 3;
  1045. $result['msg'] = '登录失效';
  1046. echo json_encode($result);
  1047. die();
  1048. }
  1049. //cur_rel:cur_rel,cur2_rel:cur2_rel,cur3_rel:cur3_rel,imgs:imgs,
  1050. $data = array();
  1051. $data['order_id'] = $gpc['order_id'];
  1052. $data['goods_id'] = $gpc['goods_id'];
  1053. $data['cur_rel'] = 5;
  1054. $data['cur2_rel'] = 5;
  1055. $data['cur3_rel'] = 5;
  1056. $data['imgs'] = $gpc['imgs'];
  1057. $data['comment_content'] = $gpc['comment_content'];
  1058. $order_id = $data['order_id'];
  1059. $goods_id = $data['goods_id'];
  1060. $cur_rel = empty($data['cur_rel']) ? 5:$data['cur_rel'];
  1061. $cur2_rel = empty($data['cur2_rel']) ? 5:$data['cur2_rel'];
  1062. $cur3_rel = empty($data['cur3_rel']) ? 5:$data['cur3_rel'];
  1063. $imgs = $data['imgs'];
  1064. $comment_content = htmlspecialchars($data['comment_content']);
  1065. $order_goods = M('lionfish_comshop_order_goods')->field('name,goods_images')->where( array('goods_id' => $goods_id,'order_id' => $order_id) )->find();
  1066. $order_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $order_id) )->find();
  1067. $member_info = M('lionfish_comshop_member')->field('username as uname , avatar')->where( array('member_id' => $member_id) )->find();
  1068. //ims_
  1069. $data = array();
  1070. $data['member_id'] = $member_id;
  1071. $data['order_id'] = $order_id;
  1072. $data['goods_id'] = $goods_id;
  1073. $data['goods_name'] = $order_goods['name'];
  1074. $data['goods_image'] = $order_goods['goods_images'];
  1075. $data['order_num_alias'] = $order_info['order_num_alias'];
  1076. $data['avatar'] = $member_info['avatar'];
  1077. $data['user_name'] = $member_info['uname'];
  1078. //open_comment_shenhe state state
  1079. $open_comment_shenhe = D('Home/Front')->get_config_by_name('open_comment_shenhe');
  1080. if( empty($open_comment_shenhe) || $open_comment_shenhe == 0 )
  1081. {
  1082. $data['state'] = 1;
  1083. }
  1084. $data['star'] = $cur_rel;
  1085. $data['star2'] = $cur2_rel;
  1086. $data['star3'] = $cur3_rel;
  1087. $data['images'] = serialize($imgs);
  1088. $data['is_picture'] = empty($imgs) ? 0 :1;
  1089. $data['content'] = $comment_content;
  1090. $data['add_time'] = time();
  1091. $comment_id = M('lionfish_comshop_order_comment')->add($data);
  1092. if(isset($data['state']) && $data['state'] == 1){
  1093. //好评有礼送积分
  1094. D('Seller/Order')->sendCommentGift($comment_id);
  1095. M('lionfish_comshop_order_comment')->where(array('comment_id'=>$comment_id,'member_id'=>$member_id))->save(array('is_send_point'=>1));
  1096. }
  1097. //TOD...暂时屏蔽
  1098. // $goods_info = M('goods')->field('store_id')->where( array('goods_id' => $goods_id) )->find();
  1099. // $group_info = M('group')->field('seller_id')->where( array('seller_id' => $goods_info['store_id']) )->find();
  1100. //判断所有订单都评价了吗?
  1101. $comment_all_order = true;
  1102. //lionfish_comshop_order_goods
  1103. $order_goods_all = M('lionfish_comshop_order_goods')->field('goods_id')->where( array('order_id' => $order_id) )->select();
  1104. foreach($order_goods_all as $val)
  1105. {
  1106. $order_comment = M('lionfish_comshop_order_comment')->field('comment_id')->where( array('goods_id' => $val['goods_id'],'order_id' =>$order_id) )->find();
  1107. if(empty($order_comment))
  1108. {
  1109. $comment_all_order = false;
  1110. break;
  1111. }
  1112. }
  1113. if($comment_all_order)
  1114. {
  1115. $order_history = array();
  1116. $order_history['order_id'] = $order_id;
  1117. $order_history['order_status_id'] = 11;
  1118. $order_history['notify'] = 0;
  1119. $order_history['comment'] = '用户提交评论,订单完成。';
  1120. $order_history['date_added']=time();
  1121. M('lionfish_comshop_order_history')->add($order_history);
  1122. //ims_
  1123. M('lionfish_comshop_order')->where( array('order_id' => $order_id) )->save( array('order_status_id' => 11,'finishtime' => time()) );
  1124. }
  1125. echo json_encode( array('code' => 1) );
  1126. die();
  1127. }
  1128. //begin....
  1129. /**
  1130. 会员积分流水
  1131. controller: user.get_user_integral_flow
  1132. token,
  1133. page
  1134. 返回:
  1135. code=0 有数据,code=1 没有数据。
  1136. 金额:money,
  1137. 时间: charge_time
  1138. 状态 state:1 充值成功,3 余额支付
  1139. **/
  1140. public function get_user_integral_flow()
  1141. {
  1142. $_GPC = I('request.');
  1143. $token = $_GPC['token'];
  1144. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1145. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1146. {
  1147. echo json_encode( array('code' => 1) );
  1148. die();
  1149. }
  1150. $member_id = $weprogram_token['member_id'];
  1151. if( empty($member_id) )
  1152. {
  1153. $result['code'] = 1;
  1154. $result['msg'] = '登录失效';
  1155. echo json_encode($result);
  1156. die();
  1157. }
  1158. $per_page = 20;
  1159. $page = isset($_GPC['page']) ? $_GPC['page'] : 1;
  1160. $offset = ($page - 1) * $per_page;
  1161. $list = array();
  1162. $list = M('lionfish_comshop_member_integral_flow')->where(" member_id = ".$member_id." ")->order('id desc')->limit($offset,$per_page)->select();
  1163. if( !empty($list) )
  1164. {
  1165. foreach($list as &$value)
  1166. {
  1167. $value['current_yuer'] = $value['after_operate_score'];
  1168. $value['addtime'] = date('Y-m-d H:i:s', $value['addtime']);
  1169. if( in_array($value['type'], array('goodsbuy','refundorder','orderbuy','pintuan_rebate') ))
  1170. {
  1171. $od_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $value['order_id'] ) )->find();
  1172. if( !empty($od_info) )
  1173. {
  1174. $value['trans_id'] = $od_info['order_num_alias'];
  1175. }
  1176. $order_goods_info = M('lionfish_comshop_order_goods')->field('name')->where( array('order_goods_id' => $value['order_goods_id']) )->find();
  1177. $value['goods_name'] = $order_goods_info['name'];
  1178. }
  1179. }
  1180. echo json_encode( array('code' => 0, 'data' => $list) );
  1181. die();
  1182. }else{
  1183. echo json_encode( array('code' => 1) );
  1184. die();
  1185. }
  1186. }
  1187. //end...
  1188. //----begin---
  1189. /**
  1190. 会员充值流水
  1191. controller: user.get_user_charge_flow
  1192. token,
  1193. page
  1194. 返回:
  1195. code=0 有数据,code=1 没有数据。
  1196. 金额:money,
  1197. 时间: charge_time
  1198. 状态 state:1 充值成功,3 余额支付
  1199. **/
  1200. public function get_user_charge_flow()
  1201. {
  1202. $_GPC = I('request.');
  1203. $token = $_GPC['token'];
  1204. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1205. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1206. {
  1207. echo json_encode( array('code' => 1) );
  1208. die();
  1209. }
  1210. $member_id = $weprogram_token['member_id'];
  1211. $per_page = 20;
  1212. $page = isset($_GPC['page']) ? $_GPC['page'] : 1;
  1213. $offset = ($page - 1) * $per_page;
  1214. $list = array();
  1215. $sql = 'select * from '.C('DB_PREFIX')."lionfish_comshop_member_charge_flow
  1216. where member_id = ".$member_id." and state in (1,3,4,5,8,9,10,11,12,20,21) order by id desc limit {$offset},{$per_page}";
  1217. $list = M()->query($sql);
  1218. if( !empty($list) )
  1219. {
  1220. foreach($list as &$value)
  1221. {
  1222. $value['current_yuer'] = $value['operate_end_yuer'];
  1223. $value['charge_time'] = date('Y-m-d H:i:s', $value['charge_time']);
  1224. if($value['state'] == 3 || $value['state'] == 4 || $value['state'] == 21)
  1225. {
  1226. $od_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $value['trans_id'] ) )->find();
  1227. if( !empty($od_info) )
  1228. {
  1229. $value['trans_id'] = $od_info['order_num_alias'];
  1230. }
  1231. //6
  1232. if( $value['state'] == 4 && !empty($value['order_goods_id']) && $value['order_goods_id'] > 0 )
  1233. {
  1234. $value['state'] = 6;
  1235. }
  1236. }
  1237. }
  1238. echo json_encode( array('code' => 0, 'data' => $list) );
  1239. die();
  1240. }else{
  1241. echo json_encode( array('code' => 1) );
  1242. die();
  1243. }
  1244. }
  1245. //----end----
  1246. /**
  1247. 获取用户信息 can_yupay show_user_pin
  1248. **/
  1249. public function get_user_info()//
  1250. {
  1251. $gpc = I('request.');
  1252. $token = $gpc['token'];
  1253. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1254. $needAuth = false;
  1255. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1256. {
  1257. $needAuth = true;
  1258. //echo json_encode( array('code' => 1) );
  1259. //die();
  1260. }
  1261. $member_id = $weprogram_token['member_id'];
  1262. if($member_id){
  1263. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
  1264. $member_info['full_user_name'] = base64_decode($member_info['full_user_name']);
  1265. // AFTER TO DO .
  1266. $member_level_list = array();
  1267. $level_name = '';
  1268. $is_show_member_level = D('Home/Front')->get_config_by_name('is_show_member_level');
  1269. $member_level_arr = array(
  1270. 0 => array('level_name' => '普通会员', 'discount' => 100),
  1271. );
  1272. $mb_level_list = M('lionfish_comshop_member_level')->where(1)->order('id asc')->select();
  1273. if( !empty($mb_level_list) )
  1274. {
  1275. foreach( $mb_level_list as $val )
  1276. {
  1277. $tmp = array();
  1278. $tmp['level_name'] = $val['levelname'];
  1279. $tmp['discount'] = $val['discount'];
  1280. $member_level_arr[$val['id']] = $tmp;
  1281. }
  1282. }
  1283. $member_info['is_show_member_level'] = $is_show_member_level;//是否显示会员等级信息
  1284. $member_info['member_level_info'] = $member_level_arr[ $member_info['level_id'] ];
  1285. $opencommiss = D('Home/Front')->get_config_by_name('commiss_level');
  1286. //待付款数量
  1287. $wait_pay_count = D('Home/Frontorder')->get_member_order_count($member_id," and order_status_id =3 ");
  1288. //待配送数量
  1289. $wait_send_count = D('Home/Frontorder')->get_member_order_count($member_id," and order_status_id = 1 and type <> 'ignore' ");
  1290. //待提货数量
  1291. $wait_get_count = D('Home/Frontorder')->get_member_order_count($member_id," and order_status_id =4 ");
  1292. //已提货数量
  1293. $has_get_count = D('Home/Frontorder')->get_member_order_count($member_id," and order_status_id in(6,11) ");
  1294. //售后退款
  1295. $refund_send_count = D('Home/Frontorder')->get_member_order_count($member_id," and order_status_id in(7,12,13) ");
  1296. $head_info = D('Home/Front')->get_member_community_info($member_id);
  1297. if( empty($head_info) )
  1298. {
  1299. $member_info['is_head'] = 0;
  1300. }else{
  1301. if($head_info['state'] == 1)
  1302. $member_info['is_head'] = 1;
  1303. else if($head_info['state'] == 0)
  1304. {
  1305. $member_info['is_head'] = 2;
  1306. }
  1307. else if($head_info['state'] == 2)
  1308. {
  1309. $member_info['is_head'] = 3;
  1310. }
  1311. }
  1312. $wechat_div = D('Home/Front')->get_config_by_name("wechat_div");
  1313. $wechat_div = $wechat_div?$wechat_div:"微信";
  1314. $member_info['wechat_div'] = $wechat_div;
  1315. $member_info['wait_pay_count'] = $wait_pay_count;
  1316. $member_info['wait_send_count'] = $wait_send_count;
  1317. $member_info['wait_get_count'] = $wait_get_count;
  1318. $member_info['has_get_count'] = $has_get_count;
  1319. //判断是否有提货码,没有就生成 hexiao_qrcod
  1320. // lionfish_comshop/moduleA/groupCenter/pendingDeliveryOrders?memberId=49
  1321. if( empty($member_info['hexiao_qrcod']))
  1322. {
  1323. $path = "lionfish_comshop/moduleA/groupCenter/pendingDeliveryOrders";
  1324. $hexiao_qrcod = D('Home/Pingoods')->_get_commmon_wxqrcode($path, $member_id);
  1325. if( empty($hexiao_qrcod) )
  1326. {
  1327. $member_info['hexiao_qrcod'] = '';
  1328. }else{
  1329. M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->save( array('hexiao_qrcod' => $hexiao_qrcod) );
  1330. $member_info['hexiao_qrcod'] = tomedia($hexiao_qrcod);
  1331. }
  1332. }else{
  1333. $member_info['hexiao_qrcod'] = tomedia($member_info['hexiao_qrcod']);
  1334. }
  1335. //判断是否是核销员
  1336. $salesroom_member_info = M('lionfish_comshop_salesroom_member')->where( array('member_id' => $member_id,'state'=>1) )->find();
  1337. if(!empty($salesroom_member_info)){
  1338. $member_info['is_hexiao_member'] = 1;
  1339. }else{
  1340. $member_info['is_hexiao_member'] = 0;
  1341. }
  1342. $is_show_member_id = D('Home/Front')->get_config_by_name('is_show_member_id');
  1343. $member_info['is_show_member_id'] = $is_show_member_id;
  1344. $supp_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  1345. $is_supply = 0; //未申请 2审核通过 1审核中
  1346. if( !empty($supp_info) ){
  1347. $is_supply = ($supp_info['state'] == 1) ? 2 : 1;
  1348. }
  1349. $is_show_auth_mobile = D('Home/Front')->get_config_by_name('is_show_auth_mobile');
  1350. if( empty($is_show_auth_mobile) )
  1351. {
  1352. $is_show_auth_mobile = 0;
  1353. }
  1354. //分销等级,如果是0,那么就是未开启分销
  1355. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  1356. if( empty($commiss_level) )
  1357. {
  1358. $commiss_level = 0;
  1359. }
  1360. //是否需要分享多少人成为分销
  1361. $commiss_sharemember_need = D('Home/Front')->get_config_by_name('commiss_sharemember_need');
  1362. //分享多少个人成为分销商
  1363. $commiss_share_member_update = D('Home/Front')->get_config_by_name('commiss_share_member_update');
  1364. //是否需要填写表单
  1365. $commiss_biaodan_need = D('Home/Front')->get_config_by_name('commiss_biaodan_need');
  1366. //是否需要审核
  1367. $commiss_become_condition = D('Home/Front')->get_config_by_name('commiss_become_condition');
  1368. //自定义表单格式
  1369. $commiss_diy_form = D('Home/Front')->get_config_by_name('commiss_diy_form');
  1370. $commiss_diy_name = D('Home/Front')->get_config_by_name('commiss_diy_name');
  1371. $share_member_count = M('lionfish_comshop_member')->where( "share_id={$member_id} and (agentid =0 or agentid={$member_id} )" )->count();
  1372. $create_time = strtotime( date('Y-m-d').' 00:00:00' );
  1373. $today_share_member_count = M('lionfish_comshop_member')->where( "share_id={$member_id} and (agentid =0 or agentid={$member_id}) and create_time>={$create_time}" )->count();
  1374. $create_y_time = $create_time - 86400;
  1375. $create_end_time = $create_time;
  1376. $yestoday_share_member_count = M('lionfish_comshop_member')->where( "share_id={$member_id} and (agentid =0 or agentid={$member_id}) and create_time>={$create_y_time} and create_time < {$create_end_time}" )->count();
  1377. //佣金团收益金额, 已结算多少钱,未结算多少钱
  1378. $pintuan_money = 0;
  1379. $pintuan_hasstatement_money = 0;
  1380. $pintuan_unstatement_money =0;
  1381. $pin_commiss = M('lionfish_comshop_pintuan_commiss')->where( array('member_id' => $member_id ) )->find();
  1382. if( !empty($pin_commiss) )
  1383. {
  1384. $pintuan_money = $pin_commiss['money'] + $pin_commiss['dongmoney']+ $pin_commiss['getmoney'];
  1385. }
  1386. $tp_hasstatement_money = M('lionfish_comshop_pintuan_commiss_order')->where( array('member_id' => $member_id, 'state' => 1) )->sum('money');
  1387. if( !empty($tp_hasstatement_money) && $tp_hasstatement_money > 0 )
  1388. {
  1389. $pintuan_hasstatement_money = $tp_hasstatement_money;
  1390. }
  1391. $tp_unstatement_money = M('lionfish_comshop_pintuan_commiss_order')->where( array('member_id' => $member_id,'state' => 0 ) )->sum('money');
  1392. if( !empty($tp_unstatement_money) && $tp_unstatement_money > 0 )
  1393. {
  1394. $pintuan_unstatement_money = $tp_unstatement_money;
  1395. }
  1396. $isopen_presale = D('Home/Front')->get_config_by_name('isopen_presale');
  1397. $isopen_presale = empty($isopen_presale) ? 0 : 1;
  1398. //是否开启礼品卡活动 begin
  1399. $isopen_virtualcard = D('Home/Front')->get_config_by_name('isopen_virtualcard');
  1400. $is_open_virtualcard_show = D('Home/Front')->get_config_by_name('is_open_virtualcard_show');
  1401. //礼品卡中心
  1402. $virtualcard_name_modify = D('Home/Front')->get_config_by_name('virtualcard_name_modify');
  1403. $virtualcard_name_modify = !isset($virtualcard_name_modify) || empty($virtualcard_name_modify) ? '礼品卡中心' : $virtualcard_name_modify;
  1404. if( isset($isopen_virtualcard) && $isopen_virtualcard == 1 )
  1405. {
  1406. $is_open_virtualcard_show = !isset($is_open_virtualcard_show) ? 0 : $is_open_virtualcard_show;
  1407. }else{
  1408. $is_open_virtualcard_show = 0;
  1409. }
  1410. //end
  1411. $result = array();
  1412. $result['code'] = 0;
  1413. $result['data'] = $member_info;
  1414. $result['is_supply'] = $is_supply;
  1415. $result['is_show_auth_mobile'] = $is_show_auth_mobile;
  1416. $result['commiss_level'] = $commiss_level;
  1417. $result['share_member_count'] = $share_member_count;
  1418. $result['today_share_member_count'] = $today_share_member_count;
  1419. $result['yestoday_share_member_count'] = $yestoday_share_member_count;
  1420. $result['commiss_sharemember_need'] = $commiss_sharemember_need;
  1421. $result['commiss_share_member_update'] = $commiss_share_member_update;
  1422. $result['commiss_biaodan_need'] = $commiss_biaodan_need;
  1423. $result['commiss_diy_form'] = unserialize($commiss_diy_form);
  1424. $result['commiss_become_condition'] = $commiss_become_condition;
  1425. $result['pintuan_money'] = $pintuan_money;
  1426. $result['pintuan_hasstatement_money'] = $pintuan_hasstatement_money;
  1427. $result['pintuan_unstatement_money'] = $pintuan_unstatement_money;
  1428. $result['isopen_presale'] = $isopen_presale;
  1429. $result['is_open_virtualcard_show'] = $is_open_virtualcard_show;//是否开启 礼品卡会员中心入口
  1430. $result['virtualcard_name_modify'] = $virtualcard_name_modify;//礼品卡中心名称自定义
  1431. //是否开启供应商手机端 member_id
  1432. $supply_is_open_mobilemanage = D('Home/Front')->get_config_by_name('supply_is_open_mobilemanage');
  1433. if( empty($supply_is_open_mobilemanage) || $supply_is_open_mobilemanage == 0 )
  1434. {
  1435. $supply_is_open_mobilemanage = 0;
  1436. }
  1437. $result['is_open_supplymobile'] = 0;
  1438. $supply_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  1439. if( !empty($supply_info) && $supply_info['state'] == 1 && $supply_info['type'] == 1 && $supply_info['is_open_mobilemanage'] == 1 )
  1440. {
  1441. $result['is_open_supplymobile'] = 1;
  1442. }
  1443. } else {
  1444. $result = array();
  1445. $result['code'] = 0;
  1446. $result['is_open_supplymobile'] = 0;
  1447. }
  1448. //判断是否开启了 会员卡 is_open_vipcard_buy
  1449. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1450. $modify_vipcard_name = D('Home/Front')->get_config_by_name('modify_vipcard_name');
  1451. $modify_vipcard_logo = D('Home/Front')->get_config_by_name('modify_vipcard_logo');
  1452. $modify_vipcard_name = empty($modify_vipcard_name) ? '天机会员': $modify_vipcard_name;
  1453. if( !empty($modify_vipcard_logo) )
  1454. {
  1455. $modify_vipcard_logo = tomedia($modify_vipcard_logo);
  1456. }
  1457. $result['is_open_vipcard_buy'] = $is_open_vipcard_buy;
  1458. $result['modify_vipcard_name'] = $modify_vipcard_name;
  1459. $result['modify_vipcard_logo'] = $modify_vipcard_logo;
  1460. $result['is_vip_card_member'] = 0;
  1461. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1462. {
  1463. //card_id //card_begin_time //card_end_time
  1464. $now_time = time();
  1465. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1466. {
  1467. $result['is_vip_card_member'] = 1;//还有会员
  1468. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1469. $result['is_vip_card_member'] = 2;//已过期
  1470. }
  1471. }
  1472. //判断是否开启了 会员卡 is_open_vipcard_buy
  1473. $is_open_vipcard_buy = D('Home/Front')->get_config_by_name('is_open_vipcard_buy');
  1474. $modify_vipcard_name = D('Home/Front')->get_config_by_name('modify_vipcard_name');
  1475. $modify_vipcard_logo = D('Home/Front')->get_config_by_name('modify_vipcard_logo');
  1476. $modify_vipcard_name = empty($modify_vipcard_name) ? '天机会员': $modify_vipcard_name;
  1477. if( !empty($modify_vipcard_logo) )
  1478. {
  1479. $modify_vipcard_logo = tomedia($modify_vipcard_logo);
  1480. }
  1481. $result['is_open_vipcard_buy'] = $is_open_vipcard_buy;
  1482. $result['modify_vipcard_name'] = $modify_vipcard_name;
  1483. $result['modify_vipcard_logo'] = $modify_vipcard_logo;
  1484. $result['is_vip_card_member'] = 0;
  1485. if( !empty($is_open_vipcard_buy) && $is_open_vipcard_buy == 1 )
  1486. {
  1487. //card_id //card_begin_time //card_end_time
  1488. $now_time = time();
  1489. if( $member_info['card_id'] >0 && $member_info['card_end_time'] > $now_time )
  1490. {
  1491. $result['is_vip_card_member'] = 1;//还有会员
  1492. }else if( $member_info['card_id'] >0 && $member_info['card_end_time'] < $now_time ){
  1493. $result['is_vip_card_member'] = 2;//已过期
  1494. }
  1495. }
  1496. //判断是否开启同城配送begin
  1497. $isopen_localtown_delivery = D('Home/Front')->get_config_by_name('isopen_localtown_delivery');
  1498. $isopen_localtown_delivery = isset($isopen_localtown_delivery) && $isopen_localtown_delivery > 0 ? $isopen_localtown_delivery: 0;
  1499. $result['is_localtown_distributionman'] = 0;//是否同城配送员,1是,0 不是
  1500. if( $isopen_localtown_delivery == 1 && $member_id > 0 )
  1501. {
  1502. $orderdistribution = M('lionfish_comshop_orderdistribution')->where( array('member_id' => $member_id ) )->find();
  1503. if( !empty($orderdistribution) )
  1504. {
  1505. $result['is_localtown_distributionman'] = 1;
  1506. }
  1507. }
  1508. //end
  1509. //签到奖励 begin
  1510. $isopen_signinreward = D('Home/Front')->get_config_by_name('isopen_signinreward');
  1511. $show_signinreward_icon = D('Home/Front')->get_config_by_name('show_signinreward_icon');
  1512. if( empty($isopen_signinreward) )
  1513. {
  1514. $isopen_signinreward = 0;
  1515. }
  1516. if( empty($show_signinreward_icon) )
  1517. {
  1518. $show_signinreward_icon = 0;
  1519. }
  1520. $result['show_user_tuan_mobile'] = D('Home/Front')->get_config_by_name('show_user_tuan_mobile');
  1521. $result['isopen_signinreward'] = $isopen_signinreward;
  1522. $result['show_signinreward_icon'] = $show_signinreward_icon;
  1523. //签到奖励 end
  1524. $result['commiss_diy_name'] = D('Home/Front')->get_config_by_name('commiss_diy_name');
  1525. $result['user_tool_showtype'] = D('Home/Front')->get_config_by_name('user_tool_showtype');
  1526. $result['needAuth'] = $needAuth;
  1527. //判断是否开启邀新有礼begin
  1528. $is_open_invite_invitation = D('Home/Front')->get_config_by_name('is_invite_open_status');
  1529. $is_open_invite_invitation = !empty($is_open_invite_invitation) ? $is_open_invite_invitation : 0;
  1530. $result['is_open_invite_invitation'] = $is_open_invite_invitation;
  1531. //end
  1532. //判断是否开启平台入口
  1533. $isopen_admin_managefront = D('Home/Front')->get_config_by_name('isopen_admin_managefront');
  1534. $isopen_admin_managefront = isset($isopen_admin_managefront) ? $isopen_admin_managefront : 0;
  1535. if($isopen_admin_managefront == 1)
  1536. {
  1537. //检测是否平台管理员
  1538. $platform_admin_member = D('Home/Front')->get_config_by_name('platform_admin_member');
  1539. $platform_admin_member_arr = explode(',', $platform_admin_member );
  1540. if( !empty($platform_admin_member_arr) && in_array( $member_id , $platform_admin_member_arr ) )
  1541. {
  1542. $isopen_admin_managefront = 1;
  1543. }else{
  1544. $isopen_admin_managefront = 0;
  1545. }
  1546. }
  1547. $result['isopen_admin_managefront'] = $isopen_admin_managefront;
  1548. $result['isopen_virtualcard'] = D('Home/Front')->get_config_by_name('isopen_virtualcard');
  1549. $result['isopen_virtualcard'] = $isopen_virtualcard;
  1550. //end..
  1551. echo json_encode( $result );
  1552. die();
  1553. }
  1554. public function supply_apply()
  1555. {
  1556. $gpc = I('request.');
  1557. $token = $gpc['token'];
  1558. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1559. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  1560. {
  1561. echo json_encode( array('code' => 1) );
  1562. die();
  1563. }
  1564. $member_id = $weprogram_token['member_id'];
  1565. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->find();
  1566. $supp_info = M('lionfish_comshop_supply')->where( array('member_id' => $member_id) )->find();
  1567. if( !empty($supp_info) )
  1568. {
  1569. echo json_encode( array('code' => 1,'msg' => '您已经申请过了') );
  1570. die();
  1571. }
  1572. $data = array();
  1573. $data['name'] = $gpc['name'];
  1574. $data['shopname'] = $gpc['shopname'];
  1575. $data['member_id'] = $member_id;
  1576. $data['logo'] = $gpc['logo'];
  1577. $data['mobile'] = $gpc['mobile'];
  1578. $data['product'] = $gpc['product'];
  1579. $data['apptime'] = 0;
  1580. $data['state'] = 0;
  1581. $data['addtime'] = time();
  1582. if( empty($data['name']) )
  1583. {
  1584. echo json_encode( array('code' => 1,'msg' => '供应商联系人不能为空') );
  1585. die();
  1586. }
  1587. if( empty($data['shopname']) )
  1588. {
  1589. echo json_encode( array('code' => 1,'msg' => '供应商名称不能为空') );
  1590. die();
  1591. }
  1592. if( empty($data['mobile']) )
  1593. {
  1594. echo json_encode( array('code' => 1,'msg' => '供应商手机号不能为空') );
  1595. die();
  1596. }
  1597. M('lionfish_comshop_supply')->add($data);
  1598. echo json_encode( array('code' => 0) );
  1599. die();
  1600. }
  1601. public function get_member_form_id()
  1602. {
  1603. $gpc = I('request.');
  1604. $token = $gpc['token']; //I('get.token');
  1605. $from_id = $gpc['from_id']; //I('get.from_id');
  1606. if($from_id != 'the formId is a mock one')
  1607. {
  1608. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1609. $member_id = $weprogram_token['member_id'];
  1610. $member_formid_data = array();
  1611. $member_formid_data['member_id'] = $member_id;
  1612. $member_formid_data['state'] = 0;
  1613. $member_formid_data['formid'] = $from_id;
  1614. $member_formid_data['addtime'] = time();
  1615. M('lionfish_comshop_member_formid')->add( $member_formid_data );
  1616. }
  1617. echo json_encode( array('code' => 1) );
  1618. die();
  1619. }
  1620. public function getPhoneNumber()
  1621. {
  1622. $_GPC = I('request.');
  1623. $iv = $_GPC['iv'];
  1624. $encryptedData = $_GPC['encryptedData'];
  1625. $token = $_GPC['token'];
  1626. $res = $this->decryptData($encryptedData, $iv, $token);
  1627. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  1628. if(empty($weprogram_token) || empty($weprogram_token['member_id']))
  1629. {
  1630. echo json_encode( array('code' => 1) );
  1631. die();
  1632. }
  1633. $member_id = $weprogram_token['member_id'];
  1634. $phoneNumber = $res->phoneNumber;
  1635. if($phoneNumber){
  1636. $param = array();
  1637. $param['telephone'] = $phoneNumber;
  1638. M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->save($param);
  1639. $result = array('code' => 0, 'phoneNumber' =>$phoneNumber);
  1640. } else{
  1641. $result = array('code' => 1, 'msg' => '获取失败,请手动输入手机号', 'error' => $res);
  1642. }
  1643. echo json_encode($result);
  1644. die();
  1645. }
  1646. // 小程序解密
  1647. public function decryptData($encryptedData, $iv, $token)
  1648. {
  1649. $caceh_data = S('wepro_'.$token);
  1650. $session_info = M('lionfish_comshop_weprogram_token')->where( array('token' => $token ) )->find();
  1651. $session_key = '';
  1652. if(!empty($session_info) && !empty($session_info['session_key'])) $session_key = $session_info['session_key'];
  1653. $appid_info = M('lionfish_comshop_config')->where( array('name' => 'wepro_appid') )->find();
  1654. if (strlen($session_key) != 24) {
  1655. return -41001;
  1656. }
  1657. $aesKey=base64_decode($session_key);
  1658. if (strlen($iv) != 24) {
  1659. return -41002;
  1660. }
  1661. $aesIV=base64_decode($iv);
  1662. $aesCipher=base64_decode($encryptedData);
  1663. $result=openssl_decrypt( $aesCipher, "AES-128-CBC", $aesKey, 1, $aesIV);
  1664. $dataObj=json_decode( $result );
  1665. if( $dataObj == NULL )
  1666. {
  1667. return -41003;
  1668. }
  1669. if( $dataObj->watermark->appid != $appid_info['value'] )
  1670. {
  1671. return -41003;
  1672. }
  1673. return $dataObj;
  1674. }
  1675. public function applogin()
  1676. {
  1677. $gpc = I('request.');
  1678. $code = $gpc['code'];
  1679. $appid_info = M('lionfish_comshop_config')->where( array('name' => 'wepro_appid') )->find();
  1680. $appsecret_info = M('lionfish_comshop_config')->where( array('name' => 'wepro_appsecret') )->find();
  1681. $appid = $appid_info['value'];
  1682. $appsecret = $appsecret_info['value'];
  1683. $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appid}&secret={$appsecret}&js_code={$code}&grant_type=authorization_code";
  1684. $open_str = http_request($url);
  1685. $data = json_decode($open_str, true);
  1686. $expires_time = time() + $data['expires_in'];
  1687. $token = md5($data['openid'].time());
  1688. $token_data = array();
  1689. $token_data['wepro_openid_'.$token] = $data['openid'];
  1690. $token_data['wepro_expires_time_'.$token] = $expires_time;
  1691. $token_data['wepro_session_key_'.$token] = $data['session_key'];
  1692. $token_data['wepro_unionid_'.$token] = $data['unionid'];
  1693. S('wepro_'.$token, $token_data);
  1694. $werp_data = array();
  1695. $werp_data['token'] = $token;
  1696. $result = array('code' => 0, 'token' => $token,'openid' =>$data['openid']);
  1697. echo json_encode($result);
  1698. die();
  1699. }
  1700. public function applogin_do()
  1701. {
  1702. $gpc = I('request.');
  1703. $token = $gpc['token'];
  1704. $nickName = $gpc['nickName'];
  1705. $avatarUrl = $gpc['avatarUrl'];
  1706. $share_id = $gpc['share_id'];
  1707. $community_id = $gpc['community_id'];
  1708. $caceh_data = S('wepro_'.$token);
  1709. $openid = $caceh_data['wepro_openid_'.$token];
  1710. $expires_time = $caceh_data['wepro_expires_time_'.$token];
  1711. $session_key = $caceh_data['wepro_session_key_'.$token];
  1712. $unionid = $caceh_data['wepro_unionid_'.$token];
  1713. $orign_nickname = $nickName;
  1714. $nickName = \Lib\Weixin\WeChatEmoji::clear($nickName);
  1715. $nickName = trim($nickName);
  1716. if( empty($openid) )
  1717. {
  1718. echo json_encode(array('code' =>1,'member_id' => 0));
  1719. die();
  1720. }
  1721. $member_info = M('lionfish_comshop_member')->where( array('we_openid' => $openid) )->find();
  1722. if( !empty($unionid) && empty($member_info) )
  1723. {
  1724. $member_info = M('lionfish_comshop_member')->where( array('unionid' => $unionid) )->find();
  1725. }
  1726. $isblack = 0;
  1727. //是否可以领取礼包: 1、可以,0、不可以,2、老用户, 3、老用户且有邀请人
  1728. $is_can_collect_gift = 0;
  1729. $is_invite_open_status = D('Home/Front')->get_config_by_name('is_invite_open_status');
  1730. if(!empty($member_info) )
  1731. {
  1732. $data = array();
  1733. $data['we_openid'] = trim($openid);
  1734. $data['avatar'] = trim($avatarUrl);
  1735. $data['username'] = trim($nickName);
  1736. $data['full_user_name'] = base64_encode($orign_nickname);
  1737. $data['last_login_time'] = time();
  1738. $data['last_login_ip'] = get_client_ip();
  1739. if(!empty($is_invite_open_status) && $is_invite_open_status == 1) {
  1740. //邀新有礼
  1741. if (empty($member_info['share_id'])) {
  1742. if (intval($share_id) > 0 && $share_id != $member_info['member_id']) {
  1743. $data['share_id'] = intval($share_id);
  1744. //保存邀请记录
  1745. $is_can_collect_gift = D('Home/Invitegift')->insertInvitegiftRecord($share_id, $member_info['member_id'], 1);
  1746. }
  1747. } else {
  1748. $is_can_collect_gift = 3;
  1749. }
  1750. }
  1751. M('lionfish_comshop_member')->where( array('member_id' => $member_info['member_id'] ) )->save( $data );
  1752. /**
  1753. ims_lionfish_comshop_car
  1754. **/
  1755. $old_token_info = M('lionfish_comshop_weprogram_token')->where( array('member_id' => $member_info['member_id'] ) )->find();
  1756. if( !empty($old_token_info) )
  1757. {
  1758. M('lionfish_comshop_car')->where( array('token' => $old_token_info['token'] ) )->delete();
  1759. }
  1760. M('lionfish_comshop_weprogram_token')->where( array('member_id' => $member_info['member_id']) )->delete();
  1761. $member_id = $member_info['member_id'];
  1762. $weprogram_token_data = array();
  1763. $weprogram_token_data['token'] = $token;
  1764. $weprogram_token_data['member_id'] = $member_id;
  1765. $weprogram_token_data['session_key'] = $session_key;
  1766. $weprogram_token_data['expires_in'] = $expires_time;
  1767. M('lionfish_comshop_weprogram_token')->add($weprogram_token_data);
  1768. $isblack = $member_info['isblack'];
  1769. }else {
  1770. $data = array();
  1771. $data['openid'] = $openid;
  1772. $data['we_openid'] = trim($openid);
  1773. $data['unionid'] = trim($unionid);
  1774. $data['reg_type'] = 'weprogram';
  1775. $data['username']=trim($nickName);
  1776. $data['avatar']=trim($avatarUrl);
  1777. $data['last_login_time']=time();
  1778. $data['create_time'] = time();
  1779. $data['last_login_ip'] = get_client_ip();
  1780. $data['full_user_name'] = base64_encode($orign_nickname);
  1781. $data['account_money'] = 0;
  1782. $data['score'] = 0;
  1783. if( $share_id > 0 )
  1784. {
  1785. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  1786. if( !empty($commiss_level) && $commiss_level > 0)
  1787. {
  1788. //开启分销,判断有没有开启分享,跟上级是否分销
  1789. $share_member_info = M('lionfish_comshop_member')->field('comsiss_flag,comsiss_state')->where( array('member_id' => $share_id ) )->find();
  1790. if( $share_member_info['comsiss_flag'] == 1 && $share_member_info['comsiss_state'] ==1 )
  1791. {
  1792. //是分销身份
  1793. $data['agentid'] = $share_id;
  1794. }else{
  1795. //看当前是否开启分享判断,如果没有开启,那么分享id就是0
  1796. $commiss_sharemember_need = D('Home/Front')->get_config_by_name('commiss_sharemember_need');
  1797. if( empty($commiss_sharemember_need) || $commiss_sharemember_need == 0 )
  1798. {
  1799. //$share_id = 0;
  1800. }
  1801. }
  1802. }else{
  1803. //未开启分销:
  1804. //$share_id = 0;
  1805. }
  1806. }
  1807. $data['share_id'] = intval($share_id);
  1808. //是否开启需要审核
  1809. $is_user_shenhe = D('Home/Front')->get_config_by_name('is_user_shenhe');
  1810. if( !empty($is_user_shenhe) && $is_user_shenhe > 0){
  1811. $data['is_comsiss_audit'] = 1;
  1812. }else{
  1813. $data['is_comsiss_audit'] = 0;
  1814. }
  1815. if( !empty($is_user_shenhe) && $is_user_shenhe == 1 )
  1816. {
  1817. $data['is_apply_state'] = 0;
  1818. }else{
  1819. $data['is_apply_state'] = 1;
  1820. }
  1821. $member_id = M('lionfish_comshop_member')->add( $data );
  1822. if($community_id > 0) {
  1823. D('Seller/Community')->in_community_history($member_id, $community_id);
  1824. }
  1825. $weprogram_token_data = array();
  1826. $weprogram_token_data['token'] = $token;
  1827. $weprogram_token_data['member_id'] = $member_id;
  1828. $weprogram_token_data['session_key'] = $session_key;
  1829. $weprogram_token_data['expires_in'] = $expires_time;
  1830. M('lionfish_comshop_weprogram_token')->add($weprogram_token_data);
  1831. if( $share_id > 0 )
  1832. {
  1833. $commiss_level = D('Home/Front')->get_config_by_name('commiss_level');
  1834. if( !empty($commiss_level) && $commiss_level > 0)
  1835. {
  1836. //如果上级已经是分销了。那么就直接划到上级的名下
  1837. //检测是否填写过表单
  1838. $share_member_info = M('lionfish_comshop_member')->field('is_writecommiss_form,comsiss_flag,comsiss_state')->where( array('member_id' =>$share_id ) )->find();
  1839. if( !empty($share_member_info) )
  1840. {
  1841. if( $share_member_info['comsiss_flag'] == 1 && $share_member_info['comsiss_state'] == 1 )
  1842. {
  1843. M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->save( array('agentid' => $share_id ) );
  1844. }
  1845. }
  1846. }
  1847. if(!empty($is_invite_open_status) && $is_invite_open_status == 1){
  1848. //保存邀请记录
  1849. $is_can_collect_gift = D('Home/Invitegift')->insertInvitegiftRecord($share_id,$member_id, 0);
  1850. }
  1851. }
  1852. /**
  1853. if($share_id > 0)
  1854. {
  1855. $share_member = M('member')->field('we_openid')->where( array('member' => $share_id) )->find();
  1856. $member_formid_info = M('member_formid')->where( array('member_id' => $share_id, 'state' => 0) )->find();
  1857. //更新
  1858. if(!empty($member_formid_info))
  1859. {
  1860. $template_data['keyword1'] = array('value' => $data['name'], 'color' => '#030303');
  1861. $template_data['keyword2'] = array('value' => '普通会员', 'color' => '#030303');
  1862. $template_data['keyword3'] = array('value' => date('Y-m-d H:i:s'), 'color' => '#030303');
  1863. $template_data['keyword4'] = array('value' => '恭喜你,获得一位新成员', 'color' => '#030303');
  1864. $pay_order_msg_info = M('config')->where( array('name' => 'wxprog_member_take_in') )->find();
  1865. $template_id = $pay_order_msg_info['value'];
  1866. $url =C('SITE_URL');
  1867. $pagepath = 'pages/dan/me';
  1868. send_wxtemplate_msg($template_data,$url,$pagepath,$share_member['we_openid'],$template_id,$member_formid_info['formid']);
  1869. M('member_formid')->where( array('id' => $member_formid_info['id']) )->save( array('state' => 1) );
  1870. }
  1871. }
  1872. **/
  1873. }
  1874. //如果开启当团长模式,那么就固定去这个团长
  1875. $open_danhead_model = D('Home/Front')->get_config_by_name('open_danhead_model');
  1876. if( empty($open_danhead_model) )
  1877. {
  1878. $open_danhead_model = 0;
  1879. }
  1880. if($open_danhead_model == 1 && $member_id > 0 )
  1881. {
  1882. $default_head = M('lionfish_community_head')->field('id')->where( array('is_default' => 1) )->find();
  1883. if( !empty($default_head) )
  1884. {
  1885. D('Seller/Community')->in_community_history($member_id, $default_head['id']);
  1886. }
  1887. }
  1888. //是否开启需要强制收集表单
  1889. //是否强制手机
  1890. $isparse_formdata = 0;
  1891. $is_get_formdata = D('Home/Front')->get_config_by_name('is_get_formdata');
  1892. if( isset($is_get_formdata) && $is_get_formdata == 1 )
  1893. {
  1894. $now_member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id))->find();
  1895. if( $now_member_info['is_apply_state'] != 1 && $now_member_info['is_write_form'] != 1 )
  1896. {
  1897. $isparse_formdata = 1;
  1898. }
  1899. }
  1900. echo json_encode(array('code' =>1,'member_id' => $member_id ,'isblack' => $isblack , 'isparse_formdata' => $isparse_formdata, 'is_can_collect_gift'=>$is_can_collect_gift ));
  1901. die();
  1902. }
  1903. /**
  1904. 获取版权信息
  1905. **/
  1906. public function get_copyright()
  1907. {
  1908. $gpc = I('request.');
  1909. $info = M('lionfish_comshop_config')->field('value')->where( array('name' => 'footer_copyright_desc') )->find();
  1910. $common_header_backgroundimage = D('Home/Front')->get_config_by_name('user_header_backgroundimage');
  1911. if( !empty($common_header_backgroundimage) )
  1912. {
  1913. $common_header_backgroundimage = tomedia($common_header_backgroundimage);
  1914. }
  1915. $is_show_about_us = D('Home/Front')->get_config_by_name('is_show_about_us');
  1916. // 余额开关
  1917. $is_open_yue_pay = D('Home/Front')->get_config_by_name('is_open_yue_pay');
  1918. if( empty($is_open_yue_pay) )
  1919. {
  1920. $is_open_yue_pay = 0;
  1921. }
  1922. // 积分开关
  1923. $is_show_score = D('Home/Front')->get_config_by_name('is_show_score');
  1924. if( empty($is_show_score) )
  1925. {
  1926. $is_show_score = 0;
  1927. }
  1928. // 订单图标
  1929. $user_order_menu_icons = D('Home/Front')->get_config_by_name('user_order_menu_icons');
  1930. if( !empty($user_order_menu_icons) )
  1931. {
  1932. $user_order_menu_icons = unserialize($user_order_menu_icons);
  1933. foreach ($user_order_menu_icons as &$v) {
  1934. if(!empty($v) )
  1935. $v = tomedia($v);
  1936. }
  1937. }
  1938. // 菜单图片
  1939. $user_tool_icons = D('Home/Front')->get_config_by_name('user_tool_icons');
  1940. if( !empty($user_tool_icons) )
  1941. {
  1942. $user_tool_icons = unserialize($user_tool_icons);
  1943. foreach ($user_tool_icons as &$v) {
  1944. if(!empty($v) )
  1945. $v = tomedia($v);
  1946. }
  1947. }
  1948. //是否关闭团长申请
  1949. $close_community_apply_enter = D('Home/Front')->get_config_by_name('close_community_apply_enter');
  1950. // 退出登录
  1951. $ishow_user_loginout_btn = D('Home/Front')->get_config_by_name('ishow_user_loginout_btn');
  1952. // 供应商自定义名称
  1953. $supply_diy_name = D('Home/Front')->get_config_by_name('supply_diy_name');
  1954. //供应商申请
  1955. $enabled_front_supply = D('Home/Front')->get_config_by_name('enabled_front_supply');
  1956. if( empty($enabled_front_supply) )
  1957. {
  1958. $enabled_front_supply = 0;
  1959. }
  1960. // 客服开关
  1961. $user_service_switch = D('Home/Front')->get_config_by_name('user_service_switch');
  1962. // 提货码显示方式
  1963. $fetch_coder_type = D('Home/Front')->get_config_by_name('fetch_coder_type');
  1964. // 我的拼单
  1965. $show_user_pin = D('Home/Front')->get_config_by_name('show_user_pin');
  1966. $commiss_diy_name = D('Home/Front')->get_config_by_name('commiss_diy_name');
  1967. $show_user_change_comunity = D('Home/Front')->get_config_by_name('show_user_change_comunity');
  1968. $show_user_change_comunity_map = D('Home/Front')->get_config_by_name('show_user_change_comunity_map');
  1969. //是否单团长模式begin
  1970. $open_danhead_model = D('Home/Front')->get_config_by_name('open_danhead_model');
  1971. if( empty($open_danhead_model) )
  1972. {
  1973. $open_danhead_model = 0;
  1974. }
  1975. $default_head_info = array();
  1976. if( $open_danhead_model == 1 )
  1977. {
  1978. $default_head = M('lionfish_community_head')->field('id')->where( array('is_default' => 1) )->find();
  1979. if( !empty($default_head) )
  1980. {
  1981. $default_head_info = D('Home/Front')->get_community_byid($default_head['id'], $where);
  1982. }
  1983. }
  1984. //是否单团长模式end
  1985. //会员中心群接龙开关begin
  1986. $is_open_solitaire = D('Home/Front')->get_config_by_name('is_open_solitaire');
  1987. if( empty($is_open_solitaire) )
  1988. {
  1989. $is_open_solitaire = 0;
  1990. }
  1991. //会员中心群接龙开关 end
  1992. $user_top_font_color = D('Home/Front')->get_config_by_name('user_top_font_color');
  1993. $excharge_nav_name = D('Home/Front')->get_config_by_name('excharge_nav_name');
  1994. $hide_community_change_btn = D('Home/Front')->get_config_by_name('hide_community_change_btn');
  1995. $hide_community_change_word = D('Home/Front')->get_config_by_name('hide_community_change_word');
  1996. $close_community_index = D('Home/Front')->get_config_by_name('close_community_index');
  1997. echo json_encode(
  1998. array(
  1999. 'code' => 0,
  2000. 'data' => $info['value'],
  2001. 'common_header_backgroundimage' => $common_header_backgroundimage,
  2002. 'is_show_about_us'=> $is_show_about_us,
  2003. 'is_show_score' => $is_show_score,
  2004. 'is_open_yue_pay' => $is_open_yue_pay,
  2005. 'user_order_menu_icons' => $user_order_menu_icons,
  2006. 'user_tool_icons' => $user_tool_icons,
  2007. 'close_community_apply_enter' => $close_community_apply_enter,
  2008. 'ishow_user_loginout_btn' => $ishow_user_loginout_btn,
  2009. 'supply_diy_name' => $supply_diy_name,
  2010. 'enabled_front_supply' => $enabled_front_supply,
  2011. 'user_service_switch' => $user_service_switch,
  2012. 'fetch_coder_type' => $fetch_coder_type,
  2013. 'show_user_pin' => $show_user_pin,
  2014. 'commiss_diy_name' => $commiss_diy_name,
  2015. 'show_user_change_comunity' => $show_user_change_comunity,
  2016. 'show_user_change_comunity_map' => $show_user_change_comunity_map,
  2017. 'open_danhead_model' => $open_danhead_model,
  2018. 'default_head_info' => $default_head_info,
  2019. 'is_open_solitaire' => $is_open_solitaire,
  2020. 'user_top_font_color' => $user_top_font_color,
  2021. 'excharge_nav_name' => $excharge_nav_name,
  2022. 'hide_community_change_btn' => $hide_community_change_btn,
  2023. 'hide_community_change_word' => $hide_community_change_word,
  2024. 'close_community_index' => $close_community_index
  2025. )
  2026. );
  2027. }
  2028. public function get_about_us(){
  2029. $about_us = D('Home/Front')->get_config_by_name('personal_center_about_us');
  2030. echo json_encode( array('code' =>0, 'data' => htmlspecialchars_decode( $about_us) ) );
  2031. die();
  2032. }
  2033. // 更新资料
  2034. public function update_user_info(){
  2035. $_GPC = I('request.');
  2036. $result = array();
  2037. $result['code'] = 1;
  2038. $token = $_GPC['token'];
  2039. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2040. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  2041. {
  2042. echo json_encode( array('code' => 1) );
  2043. die();
  2044. }
  2045. $member_id = $weprogram_token['member_id'];
  2046. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  2047. if( empty($member_info) )
  2048. {
  2049. // 未登录
  2050. echo json_encode( array('code' => 2) );
  2051. die();
  2052. }
  2053. $param = array();
  2054. $param['username'] = $_GPC['nickName'];
  2055. $param['avatar'] = $_GPC['avatarUrl'];
  2056. $member_id = $_GPC['memberId'];
  2057. if($member_id && !empty($param['username']) && !empty($param['avatar']) ){
  2058. M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->save($param);
  2059. $result['code'] = 0;
  2060. }
  2061. echo json_encode($result);
  2062. die();
  2063. }
  2064. //获取账户余额
  2065. public function get_account_money(){
  2066. $gpc = I('request.');
  2067. $result = array();
  2068. $result['code'] = 1;
  2069. $result['data'] = 0;
  2070. $result['msg'] = '';
  2071. $token = $gpc['token'];
  2072. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2073. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  2074. {
  2075. $result['msg'] = '未登录';
  2076. echo json_encode( $result ); //未登录
  2077. die();
  2078. }
  2079. $member_id = $weprogram_token['member_id'];
  2080. $member_info = M('lionfish_comshop_member')->where( array('member_id' => $member_id ) )->find();
  2081. $chargetype_list = M('lionfish_comshop_chargetype')->order( 'id asc' )->select();
  2082. if( empty($chargetype_list) )
  2083. {
  2084. $chargetype_list = array();
  2085. }
  2086. $excharge_nav_name = D('Home/Front')->get_config_by_name('excharge_nav_name');
  2087. $result['excharge_nav_name'] = $excharge_nav_name;
  2088. if(!empty($member_info)) {
  2089. $result['code'] = 0;
  2090. $result['data'] = $member_info['account_money'];
  2091. $result['chargetype_list'] = $chargetype_list;
  2092. $member_charge_publish = D('Home/Front')->get_config_by_name('member_charge_publish');
  2093. $result['member_charge_publish'] = htmlspecialchars_decode($member_charge_publish);
  2094. $result['recharge_get_money'] = D('Home/Front')->get_config_by_name('recharge_get_money');
  2095. }
  2096. echo json_encode($result);
  2097. die();
  2098. }
  2099. //end...
  2100. //----begin---
  2101. /**
  2102. 配送员收入明细
  2103. controller: user.get_user_distribution_order
  2104. token,
  2105. page
  2106. 返回:code=0 有数据,code=1 没有数据。
  2107. data 配送收入列表,
  2108. **/
  2109. public function get_user_distribution_order()
  2110. {
  2111. $_GPC = I('request.');
  2112. $token = $_GPC['token'];
  2113. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2114. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  2115. {
  2116. echo json_encode( array('code' => 1) );
  2117. die();
  2118. }
  2119. $member_id = $weprogram_token['member_id'];
  2120. $orderdistribution_id = D('Home/LocaltownSnatch')->get_distribution_id_by_member_id($member_id);
  2121. if( $orderdistribution_id <= 0 )
  2122. {
  2123. echo json_encode( array('code' => 3, 'msg' => '不是配送员' ) );
  2124. die();
  2125. }
  2126. $per_page = 20;
  2127. $page = isset($_GPC['page']) ? $_GPC['page'] : 1;
  2128. $offset = ($page - 1) * $per_page;
  2129. $list = array();
  2130. $sql = "select id,order_id,state,shipping_money,is_statement,addtime from ".C('DB_PREFIX')."lionfish_comshop_orderdistribution_order "
  2131. . " where orderdistribution_id = ".$orderdistribution_id." order by id desc limit {$offset},{$per_page}";
  2132. $list = M()->query($sql);
  2133. if( !empty($list) )
  2134. {
  2135. foreach($list as &$value)
  2136. {
  2137. $value['addtime'] = date('Y-m-d H:i:s', $value['addtime']);
  2138. $order_info = M('lionfish_comshop_order')->field('order_num_alias')->where( array('order_id' => $value['order_id'] ) )->find();
  2139. $value['order_num_alias'] = $order_info['order_num_alias'];
  2140. }
  2141. echo json_encode( array('code' => 0, 'data' => $list) );
  2142. die();
  2143. }else{
  2144. echo json_encode( array('code' => 1) );
  2145. die();
  2146. }
  2147. }
  2148. //会员保存 收集表单信息
  2149. public function save_formData()
  2150. {
  2151. $gpc = I('request.');
  2152. $token = $gpc['token'];
  2153. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2154. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  2155. {
  2156. echo json_encode( array('code' => 1) );
  2157. die();
  2158. }
  2159. $member_id = $weprogram_token['member_id'];
  2160. $form_username = I('request.form_username','','htmlspecialchars');
  2161. $form_mobile = I('request.form_mobile','','htmlspecialchars');
  2162. if( empty($form_username) )
  2163. {
  2164. echo json_encode( array('code' => 1, 'message' => '真实姓名不能为空') );
  2165. die();
  2166. }
  2167. if( empty($form_mobile) )
  2168. {
  2169. echo json_encode( array('code' => 1, 'message' => '手机号不能为空') );
  2170. die();
  2171. }
  2172. $form_info = array();
  2173. $form_info['username'] = $form_username;
  2174. $form_info['mobile'] = $form_mobile;
  2175. $up_data = array();
  2176. $up_data['is_write_form'] = 1;
  2177. $up_data['form_info'] = serialize( $form_info );
  2178. M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->save( $up_data );
  2179. echo json_encode( array('code' => 0) );
  2180. die();
  2181. }
  2182. /**
  2183. * 领券中心
  2184. */
  2185. public function collect_voucher()
  2186. {
  2187. $_GPC = I('request.');
  2188. $token = $_GPC['token'];
  2189. $coupon_id = $_GPC['coupon_id'];
  2190. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2191. if( empty($weprogram_token) || empty($weprogram_token['member_id']) )
  2192. {
  2193. echo json_encode( array('code' => 1) );
  2194. die();
  2195. }
  2196. $member_id = $weprogram_token['member_id'];
  2197. if( empty($member_id) )
  2198. {
  2199. $result['code'] = 3;
  2200. $result['msg'] = '登录失效';
  2201. echo json_encode($result);
  2202. die();
  2203. }
  2204. if( empty($coupon_id) )
  2205. {
  2206. echo json_encode(array('code'=>1,'msg'=>'优惠券数据错误'));
  2207. die();
  2208. }
  2209. $category_list = M('lionfish_comshop_coupon_category')->field('id,name,status')->where( array('merchid' => 0) )->order('id desc')->select();
  2210. $category = array();
  2211. foreach($category_list as $val)
  2212. {
  2213. $category[$val['id']] = $val;
  2214. }
  2215. $params = "id in (".$coupon_id.") and ((timelimit=1 and end_time>".time().") or timelimit=0)";
  2216. $list = M('lionfish_comshop_coupon')->where($params)->order('add_time desc')->select();
  2217. $result_list = array();
  2218. $k = 0;
  2219. $nowtime = time();
  2220. foreach($list as $key => $val)
  2221. {
  2222. //验证买家是否有 优惠券
  2223. $count = M('lionfish_comshop_coupon_list')->where(array('voucher_id'=>$val['id'],'user_id'=>$member_id))->count();
  2224. if($count > 0){
  2225. $val['is_collect'] = 1;
  2226. }else{
  2227. $val['is_collect'] = 0;
  2228. }
  2229. //判断买家 是否未使用优惠券
  2230. //is_use 0 未使用,1、已使用,2 用户不存在优惠券数据
  2231. if($val['is_collect'] == 1){
  2232. $no_use_count = M('lionfish_comshop_coupon_list')->where(array('voucher_id'=>$val['id'],'user_id'=>$member_id,'consume'=>'N'))->count();
  2233. if($no_use_count > 0){
  2234. $val['is_use'] = 0;
  2235. }else{
  2236. $val['is_use'] = 1;
  2237. }
  2238. }else{
  2239. $val['is_use'] = 2;
  2240. }
  2241. //判断买家 获取的优惠券是否过期
  2242. //is_over 0、未过期,1、已过期,2 用户不存在优惠券数据
  2243. // if($val['end_time'] < $nowtime){
  2244. // $val['is_over'] = 1;
  2245. // }else{
  2246. if($val['is_collect'] == 1){
  2247. $no_over_count = M('lionfish_comshop_coupon_list')->where(array('voucher_id'=>$val['id'],'user_id'=>$member_id))->where('end_time > '.$nowtime)->count();
  2248. if($no_over_count > 0){
  2249. $val['is_over'] = 0;
  2250. }else{
  2251. $val['is_over'] = 1;
  2252. }
  2253. }else{
  2254. $val['is_over'] = 2;
  2255. }
  2256. // }
  2257. $val['tag'] = $category[$val['catid']]['name'];
  2258. $val['begin_time'] = date('Y.m.d H:i:s', $val['begin_time']);
  2259. $val['end_time'] = date('Y.m.d H:i:s', $val['end_time']);
  2260. $result_list[$k] = $val;
  2261. $k++;
  2262. }
  2263. if( empty($result_list) )
  2264. {
  2265. echo json_encode(array('code'=>1,'msg'=>'暂无优惠券数据'));
  2266. die();
  2267. }else {
  2268. echo json_encode( array('code' =>0, 'list' => $result_list) );
  2269. }
  2270. }
  2271. /**
  2272. * 获取用户真实姓名和手机号
  2273. */
  2274. public function get_realname_tel() {
  2275. $_GPC = I('request.');
  2276. $token = $_GPC['token'];
  2277. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2278. if(empty($weprogram_token) || empty($weprogram_token['member_id']))
  2279. {
  2280. echo json_encode( array('code' => 1) );
  2281. die();
  2282. }
  2283. $member_id = $weprogram_token['member_id'];
  2284. $member_info = M('lionfish_comshop_member')->field('realname,telephone')->where( array('member_id' => $member_id) )->find();
  2285. $result = array('code' => 0, 'data' =>$member_info);
  2286. echo json_encode($result);
  2287. die();
  2288. }
  2289. public function update_realname_tel() {
  2290. $_GPC = I('request.');
  2291. $token = $_GPC['token'];
  2292. $weprogram_token = M('lionfish_comshop_weprogram_token')->field('member_id')->where( array('token' => $token) )->find();
  2293. if(empty($weprogram_token) || empty($weprogram_token['member_id']))
  2294. {
  2295. echo json_encode( array('code' => 1) );
  2296. die();
  2297. }
  2298. $member_id = $weprogram_token['member_id'];
  2299. $result['code'] = 2;
  2300. $param = array();
  2301. $param['realname'] = $_GPC['realname'];
  2302. $param['telephone'] = $_GPC['telephone'];
  2303. if( $member_id ){
  2304. M('lionfish_comshop_member')->where( array('member_id' => $member_id) )->save($param);
  2305. $result['code'] = 0;
  2306. } else {
  2307. $result['message'] = "用户不存在";
  2308. }
  2309. echo json_encode($result);
  2310. die();
  2311. }
  2312. }