newleshua.php 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437
  1. <?php
  2. class Newleshua {
  3. //测试
  4. // private $leshua_agent_id = '10';
  5. // private $leshua_agent_version = '1.0';
  6. // private $leshua_agent_key = '17B10781A8C5178870197906F71749D8';
  7. //
  8. // private $leshua_agent_update_url = 'http://pos.ileshua.com:8090/api/merchant/update';
  9. // private $leshua_agent_get_url = 'http://pos.lepass.cn/api/merchant/get';
  10. // private $leshua_agent_register_url = 'http://pos.ileshua.com:8090/api/merchant/register';
  11. // private $leshua_agent_open_url = 'http://pos.lepass.cn/api/merchant/open';
  12. //正式
  13. private $leshua_agent_id = '55765';
  14. private $leshua_agent_version = '1.0';
  15. private $leshua_agent_key = 'D4B7951B628632950AA035FB64BDFAAC';
  16. //已废弃
  17. //private $leshua_agent_update_url = 'http://pos.yeahka.com/api/merchant/update.do';
  18. //private $leshua_agent_get_url = 'http://pos.yeahka.com/api/merchant/updatePos.do';
  19. //private $leshua_agent_register_url = 'http://pos.yeahka.com/api/merchant/registerPos.do';
  20. //private $leshua_agent_open_url = 'http://pos.yeahka.com/api/merchant/open.do';
  21. //
  22. //新接口2019年3月21日起生效[正式]
  23. /*private $leshua_upload_url = 'https://saas.yeahka.com/api/picture/upload';
  24. private $leshua_agent_register_url = 'https://saas.yeahka.com/api/merchant/register';
  25. private $leshua_agent_open_url = 'https://saas.yeahka.com/api/merchant/open';
  26. private $leshua_agent_update_url = 'https://saas.yeahka.com/api/merchant/update';
  27. private $leshua_agent_view_url = 'https://saas.yeahka.com/api/merchant/info_qry';
  28. private $leshua_wxpayconfig_qry_url = 'https://saas.yeahka.com/api/wechat/wxpayconfig_qry';
  29. private $leshua_wxpayconfig_set_url = 'https://saas.yeahka.com/api/wechat/wxpayconfig';*/
  30. //新接口2019年3月21日起生效[测试]
  31. /*private $leshua_upload_url = 'http://saas.lepass.cn/api/picture/upload';
  32. private $leshua_agent_register_url = 'http://saas.lepass.cn/api/merchant/register';
  33. private $leshua_agent_open_url = 'http://saas.lepass.cn/api/merchant/open';
  34. private $leshua_agent_update_url = 'http://saas.lepass.cn/api/merchant/update';
  35. private $leshua_agent_view_url_ = 'http://saas.lepass.cn/api/merchant/info_qry';*/
  36. //新接口2019年9月1日起生效[正式]
  37. private $leshua_upload_url = 'https://saas-mch.leshuazf.com/api/picture/upload';
  38. private $leshua_agent_register_url = 'https://saas-mch.leshuazf.com/api/merchant/register';
  39. private $leshua_agent_open_url = 'https://saas-mch.leshuazf.com/api/merchant/open';
  40. private $leshua_agent_update_url = 'https://saas-mch.leshuazf.com/api/merchant/update';
  41. private $leshua_agent_view_url = 'https://saas-mch.leshuazf.com/api/merchant/info_qry';
  42. private $leshua_wxpayconfig_qry_url = 'https://saas-mch.leshuazf.com/api/wechat/wxpayconfig_qry';
  43. private $leshua_wxpayconfig_set_url = 'https://saas-mch.leshuazf.com/api/wechat/wxpayconfig';
  44. //乐刷上传图片
  45. public static function uploadLeshuaPic($pic_url)
  46. {
  47. $info = [];
  48. $info['fileMD5'] = md5_file(IMAGEDOMAIN.$pic_url);
  49. $newLeshua = new Newleshua();
  50. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  51. $paramArray['version'] = $newLeshua->leshua_agent_version;
  52. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  53. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  54. $paramArray['data'] = json_encode($info);
  55. Yii::log('paramArray:'.json_encode($paramArray));
  56. $up_file = [];
  57. $up_file[] = IMAGEDOMAIN.$pic_url;
  58. Yii::log('paramArray:'.json_encode($paramArray));
  59. Yii::log('up_file:'.json_encode($up_file));
  60. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_upload_url, $paramArray, $up_file);
  61. Yii::log('result:'.$result);
  62. $res = json_decode($result,true);
  63. return $res;
  64. }
  65. /**
  66. * 乐刷进件
  67. * @Author wulingao
  68. * @DateTime 2017-10-17
  69. * @param [type] $id [description]
  70. * @return [type] [description]
  71. */
  72. public static function registerLeshuaAccount1($id)
  73. {
  74. if (!isset($id) || empty($id)){
  75. return '该客户不存在!';
  76. }
  77. $sql = 'select * from wx_leshua_apply where id = :id;';
  78. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  79. if (empty($data) || $data == false) {
  80. return '系统繁忙,请重试!';
  81. }
  82. $sql = 'select * from wx_leshua_apply where license = :license;';
  83. $license = Yii::app()->db->createCommand($sql)->queryAll(true,array(':license'=>$data['license']));
  84. if (empty($data) || $data == false || count($license) > 1) {
  85. // return '营业执照信息已经存在';
  86. }
  87. /*if ($data['merchant_type'] > 2 || $data['merchant_type'] < 1) {
  88. return '商户类型不正确!';
  89. }*/
  90. $paramArray = array();
  91. $info = array();
  92. //基本信息
  93. $info['base']['merchantType'] = $data['merchant_type'] == 2 ? 3 : $data['merchant_type'];
  94. $info['base']['name'] = $data['applicant']; //??
  95. $info['base']['idcard'] = $data['idcard'];
  96. $info['base']['mobile'] = $data['mobile'];
  97. $info['base']['merchantName'] = $data['merchant_name'];
  98. $sql1 = 'select * from wx_leshua_pos_province where tag = :tag;';
  99. $provinceData = Yii::app()->db->createCommand($sql1)->queryRow(true,array(':tag'=>$data['province_code']));
  100. if (empty($provinceData) || $provinceData == false) {
  101. return '系统繁忙,请重试2!';
  102. }
  103. $sql2 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  104. $cityData = Yii::app()->db->createCommand($sql2)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  105. if (empty($cityData) || $cityData == false) {
  106. return '系统繁忙,请重试3!';
  107. }
  108. $sql3 = 'select * from wx_leshua_pos_area where area_tag = :area_tag;';
  109. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':area_tag'=>$data['area_code']));
  110. if (empty($areaData) || $areaData == false) {
  111. $sql3 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  112. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  113. // if (empty($areaData) || $areaData == false) {
  114. // return '系统繁忙,请重试3!';
  115. // }
  116. }
  117. //商户基本信息(base)
  118. $info['base']['province'] = $provinceData['name'];
  119. $info['base']['city'] = $cityData['name'];
  120. $info['base']['area'] = !isset($areaData['name']) || empty($areaData['name']) ? $cityData['name'] : $areaData['name'];//缺地区
  121. $info['base']['address'] = $data['address'];
  122. // if ($data['merchant_type'] == 2){
  123. //企业商户必传
  124. $info['base']['license'] = $data['license'];
  125. $info['base']['licenseFullName'] = $data['license_name'];//缺营业执照注册名称
  126. $info['base']['licenseAddress'] = $data['license_address'];//缺营业执照注册地址
  127. $info['base']['licenseStart'] = $data['license_start'];
  128. $info['base']['licenseEnd'] = $data['license_end'];
  129. // }
  130. //账户信息
  131. $info['account']['type'] = $data['bank_account_type'];
  132. $info['account']['branch'] = $data['bank_branch'];
  133. $info['account']['unionpay'] = $data['bank_unionpay_code'];
  134. $info['account']['holder'] = $data['bank_holder'];
  135. $info['account']['cardId'] = $data['bank_account'];
  136. $info['account']['mobile'] = $data['bank_phone'];
  137. if($data['settle_type']==1){
  138. //法人
  139. $info['account']['legalFlag'] = 1;
  140. }else if($data['settle_type']==2){
  141. //非法人
  142. $info['account']['legalFlag'] = 0;
  143. $info['account']['bankIdCard'] = $data['un_idcard'];
  144. $info['base']['legalName'] = $data['legal_person_name'];
  145. }
  146. //其他信息
  147. // if ($data['merchant_type'] == 2){
  148. //企业商户必传
  149. if ($data['mcc_type'] == 1){
  150. $info['other']['isIndustryDining'] = 1; //餐娱类???
  151. }else{
  152. $info['other']['isIndustryDining'] = 0;
  153. }
  154. // }
  155. $info['other']['oemMerchantMode'] = 0;
  156. $info['other']['preferentialType'] = 0;
  157. $info['other']['uploadToUnionpay'] = 0;
  158. $info['other']['mccCode'] = $data['mcc_code'];
  159. $info['other']['mccType'] = $data['mcc_type'];
  160. //新增
  161. if (empty($data['appid'])) {
  162. $info['other']['publicsignalAppid'] = 'wx2e7e5a2a92bd1efe';
  163. $info['other']['gzhMerchantName'] = '深圳市迅享同城科技有限公司';
  164. } else {
  165. //必须和公众号主体一致(营业执照上公司全称一致)
  166. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  167. if (empty($data['public_pull_name'])) {
  168. if (!empty($data['license_name'])) {
  169. $info['other']['gzhMerchantName'] = $data['license_name'];
  170. } else {
  171. if (!empty($data['merchant_name'])) {
  172. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  173. }
  174. }
  175. }
  176. //公众号appid(支付)
  177. $info['other']['publicsignalAppid'] = $data['appid'];
  178. }
  179. //公众号授权目录(支付)
  180. $info['other']['publicsignalAuthorizationDirectory'] = 'https://wap-test.lewaimai.com/lewaimaigod/;https://wap-beta.lewaimai.com/lewaimaigod/;https://wap-dev.lewaimai.com/lewaimaigod/;https://wap.lewaimai.com/lewaimaigod/';
  181. //默认关注迅享同城的公众号
  182. $info['other']['publicsignalAppidGZ'] = 'wx2e7e5a2a92bd1efe';
  183. $newLeshua = new Newleshua();
  184. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  185. $paramArray['version'] = $newLeshua->leshua_agent_version;
  186. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  187. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  188. $params = array();
  189. // if ($data['merchant_type'] == 2){}
  190. $res = array('respCode'=>'1','respMsg'=>'失败');
  191. if (empty($data['idcard_front']) || empty($data['idcard_back'])) {
  192. $res['respMsg'] = '缺少身份证照片';
  193. return $res;
  194. }
  195. if (empty($data['bankcard_front'])) {
  196. $res['respMsg'] = '缺少银行卡照片';
  197. return $res;
  198. }
  199. if (empty($data['business_license_c'])) {
  200. $res['respMsg'] = '缺少公司营业执照照片';
  201. return $res;
  202. }
  203. if (empty($data['business_inside_c'])) {
  204. $res['respMsg'] = '缺少经营场所内设照片';
  205. return $res;
  206. }
  207. if (empty($data['business_door_c'])) {
  208. $res['respMsg'] = '缺少门头照片';
  209. return $res;
  210. }
  211. if (empty($data['business_cashier_desk_c'])) {
  212. $res['respMsg'] = '缺少收银台招盘照';
  213. return $res;
  214. }
  215. if (empty($data['lease_property_c'])) {
  216. $res['respMsg'] = '缺少租赁协议或房产证明照';
  217. return $res;
  218. }
  219. if($data['settle_type']==2){
  220. if (empty($data['notlegal_idcard_front'])) {
  221. $res['respMsg'] = '缺少非法人身份证正面照片';
  222. return $res;
  223. }
  224. if (empty($data['notlegal_idcard_back'])) {
  225. $res['respMsg'] = '缺少非法人身份证反面照片';
  226. return $res;
  227. }
  228. if (empty($data['authorization_letter_pic'])) {
  229. $res['respMsg'] = '缺少非法人结算书授权函照片或扫描文件';
  230. return $res;
  231. }
  232. }
  233. //企业号需传证照
  234. $params['idcardFrontPic'] = IMAGEDOMAIN.$data['idcard_front'];
  235. $params['idcardBackPic'] = IMAGEDOMAIN.$data['idcard_back'];
  236. $params['bankCardFrontPic'] = IMAGEDOMAIN.$data['bankcard_front'];
  237. $params['licensePic'] = IMAGEDOMAIN.$data['business_license_c'];
  238. $params['insidePic'] = IMAGEDOMAIN.$data['business_inside_c'];//缺经营场所内设照片
  239. $params['doorPic'] = IMAGEDOMAIN.$data['business_door_c'];//缺门头照
  240. $params['cashierDeskPic'] = IMAGEDOMAIN.$data['business_cashier_desk_c'];//缺收银台招盘照
  241. $params['agreementPic'] = IMAGEDOMAIN.$data['lease_property_c'];//租赁协议或房产证明图片
  242. if($data['settle_type']==2){
  243. $params['nonLegSettleAuthPic'] = IMAGEDOMAIN.$data['authorization_letter_pic'];
  244. $params['nonLegIdcardFrontPic'] = IMAGEDOMAIN.$data['notlegal_idcard_front'];
  245. $params['nonLlegIdcardBackPic'] = IMAGEDOMAIN.$data['notlegal_idcard_back'];
  246. }
  247. // }
  248. $paramArray['data'] = json_encode($info);
  249. Yii::log('paramArray:'.json_encode($paramArray));
  250. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_upload_url, $paramArray, $params);
  251. Yii::log('result:'.$result);
  252. $res = json_decode($result,true);
  253. return $res;
  254. }
  255. public static function registerLeshuaAccount($id)
  256. {
  257. if (!isset($id) || empty($id)){
  258. return '该客户不存在!';
  259. }
  260. $sql = 'select * from wx_leshua_apply where id = :id;';
  261. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  262. if (empty($data) || $data == false) {
  263. return '系统繁忙,请重试!';
  264. }
  265. $sql = 'select * from wx_leshua_apply where license = :license;';
  266. $license = Yii::app()->db->createCommand($sql)->queryAll(true,array(':license'=>$data['license']));
  267. if (empty($data) || $data == false || count($license) > 1) {
  268. // return '营业执照信息已经存在';
  269. }
  270. /*if ($data['merchant_type'] > 2 || $data['merchant_type'] < 1) {
  271. return '商户类型不正确!';
  272. }*/
  273. $sql1 = 'select * from wx_leshua_pos_province where tag = :tag;';
  274. $provinceData = Yii::app()->db->createCommand($sql1)->queryRow(true,array(':tag'=>$data['province_code']));
  275. if (empty($provinceData) || $provinceData == false) {
  276. return '系统繁忙,请重试2!';
  277. }
  278. $sql2 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  279. $cityData = Yii::app()->db->createCommand($sql2)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  280. if (empty($cityData) || $cityData == false) {
  281. return '系统繁忙,请重试3!';
  282. }
  283. $sql3 = 'select * from wx_leshua_pos_area where area_tag = :area_tag;';
  284. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':area_tag'=>$data['area_code']));
  285. if (empty($areaData) || $areaData == false) {
  286. $sql3 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  287. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  288. // if (empty($areaData) || $areaData == false) {
  289. // return '系统繁忙,请重试3!';
  290. // }
  291. }
  292. $adminModel = Admin::model()->findByPk($data['admin_id']);
  293. $paramArray = array();
  294. $info = array();
  295. //商户基本信息
  296. $info['baseInfo']['merchantType'] = $data['merchant_type'] == 2 ? 3 : $data['merchant_type'];
  297. $info['baseInfo']['merchantName'] = $data['merchant_name'];
  298. $info['baseInfo']['mccCode'] = $data['mcc_code'];
  299. //法人信息
  300. $info['legalPerson']['idCardNo'] = $data['idcard'];
  301. $info['legalPerson']['idcardFrontPic'] = $data['idcard_front_ls'];
  302. $info['legalPerson']['idcardBackPic'] = $data['idcard_back_ls'];
  303. if($data['settle_type']==1){//法人
  304. $info['legalPerson']['legalName'] = $data['applicant'];
  305. $info['contactInfo']['name'] = $data['applicant'];
  306. }elseif($data['settle_type']==2) {//非法人
  307. $info['legalPerson']['legalName'] = $data['legal_person_name'];
  308. $info['contactInfo']['name'] = $data['applicant'];
  309. }
  310. //联系人信息
  311. $info['contactInfo']['mobile'] = $data['mobile'];
  312. //店铺地址信息addressInfo
  313. $info['addressInfo']['province'] = $provinceData['name'];
  314. $info['addressInfo']['city'] = $cityData['name'];
  315. $info['addressInfo']['area'] = !isset($areaData['name']) || empty($areaData['name']) ? $cityData['name'] : $areaData['name'];//缺地区
  316. $info['addressInfo']['address'] = $data['address'];
  317. //营业资质信息licenseInfo
  318. $info['licenseInfo']['license'] = $data['license'];
  319. $info['licenseInfo']['licenseFullName'] = trim($data['license_name']," ");//缺营业执照注册名称
  320. $info['licenseInfo']['licenseAddress'] = $data['license_address'];//缺营业执照注册地址
  321. $info['licenseInfo']['licenseStart'] = $data['license_start'];
  322. $info['licenseInfo']['licenseEnd'] = $data['license_end'];
  323. $info['licenseInfo']['licensePic'] = $data['business_license_c_ls'];
  324. //结算信息
  325. $info['accountInfo']['type'] = $data['bank_account_type'];
  326. $info['accountInfo']['branch'] = $data['bank_branch'];
  327. $info['accountInfo']['unionpay'] = $data['bank_unionpay_code'];
  328. $info['accountInfo']['holder'] = trim($data['bank_holder']," ");
  329. $info['accountInfo']['idCardNo'] = $data['idcard'];
  330. $info['accountInfo']['mobile'] = $data['bank_phone'];
  331. $info['accountInfo']['bankCardNo'] = $data['bank_account'];
  332. $info['accountInfo']['bankCardFrontPic'] = $data['bankcard_front_ls'];
  333. if($data['settle_type']==1){ //法人
  334. $info['accountInfo']['legalFlag'] = 1;
  335. }else if($data['settle_type']==2){//非法人
  336. $info['accountInfo']['legalFlag'] = 0;
  337. $info['accountInfo']['nonLegSettleAuthPic'] = $data['authorization_letter_pic_ls'];
  338. $info['accountInfo']['nonLegIdcardFrontPic'] = $data['notlegal_idcard_front_ls'];
  339. $info['accountInfo']['nonLegIdcardBackPic'] = $data['notlegal_idcard_back_ls'];
  340. }
  341. //门店信息
  342. $info['shopInfo']['insidePic'] = $data['business_inside_c_ls'];
  343. $info['shopInfo']['doorPic'] = $data['business_door_c_ls'];
  344. $info['shopInfo']['cashierDeskPic'] = $data['business_cashier_desk_c_ls'];
  345. //微信信息
  346. $info['wechatInfo']['subAppid'] = "wx2e7e5a2a92bd1efe";
  347. $info['wechatInfo']['jsapiPath'] = 'https://wap-test.lewaimai.com/lewaimaigod/;https://wap-beta.lewaimai.com/lewaimaigod/;https://wap-dev.lewaimai.com/lewaimaigod/;https://wap.lewaimai.com/lewaimaigod/';
  348. $info['wechatInfo']['subscribeAppid'] = 'wx2e7e5a2a92bd1efe';
  349. if ($data['attention_type']==2){
  350. $info['wechatInfo']['subAppid'] = $adminModel->appid;
  351. }
  352. //其它信息otherInfo
  353. $info['wechatInfo']['otherInfo'] = [];
  354. $newLeshua = new Newleshua();
  355. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  356. $paramArray['version'] = $newLeshua->leshua_agent_version;
  357. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  358. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  359. $params = array();
  360. $res = array('respCode'=>'1','respMsg'=>'失败');
  361. if (empty($data['idcard_front']) || empty($data['idcard_back'])) {
  362. $res['respMsg'] = '缺少身份证照片';
  363. return $res;
  364. }
  365. if (empty($data['bankcard_front'])) {
  366. $res['respMsg'] = '缺少银行卡照片';
  367. return $res;
  368. }
  369. if (empty($data['business_license_c'])) {
  370. $res['respMsg'] = '缺少公司营业执照照片';
  371. return $res;
  372. }
  373. if (empty($data['business_inside_c'])) {
  374. $res['respMsg'] = '缺少经营场所内设照片';
  375. return $res;
  376. }
  377. if (empty($data['business_door_c'])) {
  378. $res['respMsg'] = '缺少门头照片';
  379. return $res;
  380. }
  381. if (empty($data['business_cashier_desk_c'])) {
  382. $res['respMsg'] = '缺少收银台招盘照';
  383. return $res;
  384. }
  385. if($data['settle_type']==2){
  386. if (empty($data['notlegal_idcard_front'])) {
  387. $res['respMsg'] = '缺少非法人身份证正面照片';
  388. return $res;
  389. }
  390. if (empty($data['notlegal_idcard_back'])) {
  391. $res['respMsg'] = '缺少非法人身份证反面照片';
  392. return $res;
  393. }
  394. if (empty($data['authorization_letter_pic'])) {
  395. $res['respMsg'] = '缺少非法人结算书授权函照片或扫描文件';
  396. return $res;
  397. }
  398. }
  399. $paramArray['data'] = json_encode($info);
  400. Yii::log('paramArray:'.json_encode($paramArray));
  401. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_register_url, $paramArray, $params);
  402. Yii::log('result:'.$result);
  403. $res = json_decode($result,true);
  404. return $res;
  405. }
  406. public static function upgradeLeshuaAccount($id)
  407. {
  408. if (!isset($id) || empty($id)){
  409. return '该客户不存在!';
  410. }
  411. $sql = 'select * from wx_leshua_apply where id = :id;';
  412. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  413. if (empty($data) || $data == false) {
  414. return '系统繁忙,请重试!';
  415. }
  416. $sql = 'select * from wx_leshua_apply where license = :license;';
  417. $license = Yii::app()->db->createCommand($sql)->queryAll(true,array(':license'=>$data['license']));
  418. if (empty($data) || $data == false || count($license) > 1) {
  419. // return '营业执照信息已经存在';
  420. }
  421. /*if ($data['merchant_type'] > 2 || $data['merchant_type'] < 1) {
  422. return '商户类型不正确!';
  423. }*/
  424. $paramArray = array();
  425. $info = array();
  426. //基本信息
  427. $info['base']['merchantId'] = $data['leshua_id'];
  428. $info['base']['merchantType'] = $data['merchant_type'] == 2 ? 3 : $data['merchant_type'];
  429. $info['base']['mobile'] = $data['mobile'];
  430. $info['base']['merchantName'] = $data['merchant_name'];
  431. $sql1 = 'select * from wx_leshua_pos_province where tag = :tag;';
  432. $provinceData = Yii::app()->db->createCommand($sql1)->queryRow(true,array(':tag'=>$data['province_code']));
  433. if (empty($provinceData) || $provinceData == false) {
  434. return '系统繁忙,请重试2!';
  435. }
  436. $sql2 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  437. $cityData = Yii::app()->db->createCommand($sql2)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  438. if (empty($cityData) || $cityData == false) {
  439. return '系统繁忙,请重试3!';
  440. }
  441. $sql3 = 'select * from wx_leshua_pos_area where area_tag = :area_tag;';
  442. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':area_tag'=>$data['area_code']));
  443. if (empty($areaData) || $areaData == false) {
  444. $sql3 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  445. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  446. // if (empty($areaData) || $areaData == false) {
  447. // return '系统繁忙,请重试3!';
  448. // }
  449. }
  450. //商户基本信息(base)
  451. $info['base']['province'] = $provinceData['name'];
  452. $info['base']['city'] = $cityData['name'];
  453. $info['base']['area'] = !isset($areaData['name']) || empty($areaData['name']) ? $cityData['name'] : $areaData['name'];//缺地区
  454. $info['base']['address'] = $data['address'];
  455. // if ($data['merchant_type'] == 2){
  456. //企业商户必传
  457. $info['base']['license'] = $data['license'];
  458. $info['base']['licenseFullName'] = $data['license_name'];//缺营业执照注册名称
  459. $info['base']['licenseAddress'] = $data['license_address'];//缺营业执照注册地址
  460. $info['base']['licenseStart'] = $data['license_start'];
  461. $info['base']['licenseEnd'] = $data['license_end'];
  462. // }
  463. //账户信息
  464. $info['account']['type'] = $data['bank_account_type'];
  465. $info['account']['branch'] = $data['bank_branch'];
  466. $info['account']['unionpay'] = $data['bank_unionpay_code'];
  467. $info['account']['holder'] = $data['bank_holder'];
  468. $info['account']['cardId'] = $data['bank_account'];
  469. $info['account']['mobile'] = $data['bank_phone'];
  470. //其他信息
  471. // if ($data['merchant_type'] == 2){
  472. //企业商户必传
  473. if ($data['mcc_type'] == 1){
  474. $info['other']['isIndustryDining'] = 1; //餐娱类???
  475. }else{
  476. $info['other']['isIndustryDining'] = 0;
  477. }
  478. // }
  479. $info['other']['oemMerchantMode'] = 0;
  480. $info['other']['preferentialType'] = 0;
  481. $info['other']['uploadToUnionpay'] = 0;
  482. $info['other']['mccCode'] = $data['mcc_code'];
  483. $info['other']['mccType'] = $data['mcc_type'];
  484. //新增
  485. if (empty($data['appid'])) {
  486. $info['other']['publicsignalAppid'] = 'wx2e7e5a2a92bd1efe';
  487. $info['other']['gzhMerchantName'] = '深圳市迅享同城科技有限公司';
  488. } else {
  489. //必须和公众号主体一致(营业执照上公司全称一致)
  490. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  491. if (empty($data['public_pull_name'])) {
  492. if (!empty($data['license_name'])) {
  493. $info['other']['gzhMerchantName'] = $data['license_name'];
  494. } else {
  495. if (!empty($data['merchant_name'])) {
  496. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  497. }
  498. }
  499. }
  500. //公众号appid(支付)
  501. $info['other']['publicsignalAppid'] = $data['appid'];
  502. }
  503. //公众号授权目录(支付)
  504. $info['other']['publicsignalAuthorizationDirectory'] = 'https://wap-test.lewaimai.com/lewaimaigod/;https://wap-beta.lewaimai.com/lewaimaigod/;https://wap-dev.lewaimai.com/lewaimaigod/;https://wap.lewaimai.com/lewaimaigod/';
  505. //默认关注迅享同城的公众号
  506. $info['other']['publicsignalAppidGZ'] = 'wx2e7e5a2a92bd1efe';
  507. $newLeshua = new Newleshua();
  508. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  509. $paramArray['version'] = $newLeshua->leshua_agent_version;
  510. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  511. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  512. $params = array();
  513. // if ($data['merchant_type'] == 2){
  514. $res = array('respCode'=>'1','respMsg'=>'失败');
  515. if (empty($data['idcard_front']) || empty($data['idcard_back'])) {
  516. $res['respMsg'] = '缺少身份证照片';
  517. return $res;
  518. }
  519. if (empty($data['bankcard_front'])) {
  520. $res['respMsg'] = '缺少银行卡照片';
  521. return $res;
  522. }
  523. if (empty($data['business_license_c'])) {
  524. $res['respMsg'] = '缺少公司营业执照照片';
  525. return $res;
  526. }
  527. if (empty($data['business_inside_c'])) {
  528. $res['respMsg'] = '缺少经营场所内设照片';
  529. return $res;
  530. }
  531. if (empty($data['business_door_c'])) {
  532. $res['respMsg'] = '缺少门头照片';
  533. return $res;
  534. }
  535. if (empty($data['business_cashier_desk_c'])) {
  536. $res['respMsg'] = '缺少收银台招盘照';
  537. return $res;
  538. }
  539. if (empty($data['lease_property_c'])) {
  540. $res['respMsg'] = '缺少租赁协议或房产证明照';
  541. return $res;
  542. }
  543. //企业号需传证照
  544. $params['idcardFrontPic'] = IMAGEDOMAIN.$data['idcard_front'];
  545. $params['idcardBackPic'] = IMAGEDOMAIN.$data['idcard_back'];
  546. $params['bankCardFrontPic'] = IMAGEDOMAIN.$data['bankcard_front'];
  547. $params['licensePic'] = IMAGEDOMAIN.$data['business_license_c'];
  548. $params['insidePic'] = IMAGEDOMAIN.$data['business_inside_c'];//缺经营场所内设照片
  549. $params['doorPic'] = IMAGEDOMAIN.$data['business_door_c'];//缺门头照
  550. $params['cashierDeskPic'] = IMAGEDOMAIN.$data['business_cashier_desk_c'];//缺收银台招盘照
  551. $params['agreementPic'] = IMAGEDOMAIN.$data['lease_property_c'];//租赁协议或房产证明图片
  552. // }
  553. $paramArray['data'] = json_encode($info);
  554. Yii::log('upgradeLeshuaAccount paramArray:'.json_encode($paramArray));
  555. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_update_url, $paramArray, $params);
  556. Yii::log('upgradeLeshuaAccount result:'.$result);
  557. $res = json_decode($result,true);
  558. return $res;
  559. }
  560. public static function completeLeshuaAccount($id)
  561. {
  562. if (!isset($id) || empty($id)){
  563. return '该客户不存在!';
  564. }
  565. $sql = 'select * from wx_leshua_apply where id = :id;';
  566. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  567. if (empty($data) || $data == false) {
  568. return '系统繁忙,请重试!';
  569. }
  570. $sql = 'select * from wx_leshua_apply where license = :license;';
  571. $license = Yii::app()->db->createCommand($sql)->queryAll(true,array(':license'=>$data['license']));
  572. if (empty($data) || $data == false || count($license) > 1) {
  573. // return '营业执照信息已经存在';
  574. }
  575. /*if ($data['merchant_type'] > 2 || $data['merchant_type'] < 1) {
  576. return '商户类型不正确!';
  577. }*/
  578. $paramArray = array();
  579. $info = array();
  580. //基本信息
  581. $info['base']['merchantType'] = $data['merchant_type'] == 2 ? 3 : $data['merchant_type'];
  582. $info['base']['name'] = $data['applicant']; //??
  583. $info['base']['idcard'] = $data['idcard'];
  584. $info['base']['mobile'] = $data['mobile'];
  585. $info['base']['merchantName'] = $data['merchant_name'];
  586. $sql1 = 'select * from wx_leshua_pos_province where tag = :tag;';
  587. $provinceData = Yii::app()->db->createCommand($sql1)->queryRow(true,array(':tag'=>$data['province_code']));
  588. if (empty($provinceData) || $provinceData == false) {
  589. return '系统繁忙,请重试2!';
  590. }
  591. $sql2 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  592. $cityData = Yii::app()->db->createCommand($sql2)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  593. if (empty($cityData) || $cityData == false) {
  594. return '系统繁忙,请重试3!';
  595. }
  596. $sql3 = 'select * from wx_leshua_pos_area where area_tag = :area_tag;';
  597. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':area_tag'=>$data['area_code']));
  598. if (empty($areaData) || $areaData == false) {
  599. $sql3 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  600. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  601. // if (empty($areaData) || $areaData == false) {
  602. // return '系统繁忙,请重试3!';
  603. // }
  604. }
  605. //商户基本信息(base)
  606. $info['base']['province'] = $provinceData['name'];
  607. $info['base']['city'] = $cityData['name'];
  608. $info['base']['area'] = !isset($areaData['name']) || empty($areaData['name']) ? $cityData['name'] : $areaData['name'];//缺地区
  609. $info['base']['address'] = $data['address'];
  610. // if ($data['merchant_type'] == 2){
  611. //企业商户必传
  612. $info['base']['license'] = $data['license'];
  613. $info['base']['licenseFullName'] = $data['license_name'];//缺营业执照注册名称
  614. $info['base']['licenseAddress'] = $data['license_address'];//缺营业执照注册地址
  615. $info['base']['licenseStart'] = $data['license_start'];
  616. $info['base']['licenseEnd'] = $data['license_end'];
  617. // }
  618. //账户信息
  619. $info['account']['type'] = $data['bank_account_type'];
  620. $info['account']['branch'] = $data['bank_branch'];
  621. $info['account']['unionpay'] = $data['bank_unionpay_code'];
  622. $info['account']['holder'] = $data['bank_holder'];
  623. $info['account']['cardId'] = $data['bank_account'];
  624. $info['account']['mobile'] = $data['bank_phone'];
  625. //其他信息
  626. // if ($data['merchant_type'] == 2){
  627. //企业商户必传
  628. if ($data['mcc_type'] == 1){
  629. $info['other']['isIndustryDining'] = 1; //餐娱类???
  630. }else{
  631. $info['other']['isIndustryDining'] = 0;
  632. }
  633. // }
  634. $info['other']['oemMerchantMode'] = 0;
  635. $info['other']['preferentialType'] = 0;
  636. $info['other']['uploadToUnionpay'] = 0;
  637. $info['other']['mccCode'] = $data['mcc_code'];
  638. $info['other']['mccType'] = $data['mcc_type'];
  639. //新增
  640. if (empty($data['appid'])) {
  641. $info['other']['publicsignalAppid'] = 'wx2e7e5a2a92bd1efe';
  642. $info['other']['gzhMerchantName'] = '深圳市迅享同城科技有限公司';
  643. } else {
  644. //必须和公众号主体一致(营业执照上公司全称一致)
  645. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  646. if (empty($data['public_pull_name'])) {
  647. if (!empty($data['license_name'])) {
  648. $info['other']['gzhMerchantName'] = $data['license_name'];
  649. } else {
  650. if (!empty($data['merchant_name'])) {
  651. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  652. }
  653. }
  654. }
  655. //公众号appid(支付)
  656. $info['other']['publicsignalAppid'] = $data['appid'];
  657. }
  658. //公众号授权目录(支付)
  659. $info['other']['publicsignalAuthorizationDirectory'] = 'https://wap-test.lewaimai.com/lewaimaigod/;https://wap-beta.lewaimai.com/lewaimaigod/;https://wap-dev.lewaimai.com/lewaimaigod/;https://wap.lewaimai.com/lewaimaigod/';
  660. //默认关注迅享同城的公众号
  661. $info['other']['publicsignalAppidGZ'] = 'wx2e7e5a2a92bd1efe';
  662. $newLeshua = new Newleshua();
  663. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  664. $paramArray['version'] = $newLeshua->leshua_agent_version;
  665. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  666. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  667. $params = array();
  668. // if ($data['merchant_type'] == 2){
  669. //企业号需传证照
  670. $params['idcardFrontPic'] = IMAGEDOMAIN.$data['idcard_front'];
  671. $params['idcardBackPic'] = IMAGEDOMAIN.$data['idcard_back'];
  672. $params['bankCardFrontPic'] = IMAGEDOMAIN.$data['bankcard_front'];
  673. $params['licensePic'] = IMAGEDOMAIN.$data['business_license_c'];
  674. $params['insidePic'] = IMAGEDOMAIN.$data['business_inside_c'];//缺经营场所内设照片
  675. $params['doorPic'] = IMAGEDOMAIN.$data['business_door_c'];//缺门头照
  676. $params['cashierDeskPic'] = IMAGEDOMAIN.$data['business_cashier_desk_c'];//缺收银台招盘照
  677. $params['agreementPic'] = IMAGEDOMAIN.$data['lease_property_c'];//租赁协议或房产证明图片
  678. // }
  679. $paramArray['data'] = json_encode($info);
  680. Yii::log('paramArray:'.json_encode($paramArray));
  681. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_update_url, $paramArray, array());
  682. Yii::log('completeLeshuaAccount result:'.$result);
  683. $result = json_decode($result,true);
  684. if (is_array($result) && $result['respCode'] == '000000' && $result['respMsg'] == '成功') {
  685. Yii::log('completeLeshuaAccount is '.$result['respMsg']);
  686. } else {
  687. Yii::log('completeLeshuaAccount result is false; '.$result['respMsg']);
  688. }
  689. return $result;
  690. }
  691. /**
  692. * 修改乐刷信息111
  693. * @Author wulingao
  694. * @DateTime 2017-10-17
  695. * @param [type] $id [description]
  696. * @return [type] [description]
  697. */
  698. public static function editLeshuaAccount($id)
  699. {
  700. if (!isset($id) || empty($id)){
  701. return '该客户不存在!';
  702. }
  703. $sql = 'select * from wx_leshua_apply where id = :id;';
  704. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  705. if (empty($data) || $data == false) {
  706. return '系统繁忙,请重试!';
  707. }
  708. $sql = 'select * from wx_leshua_apply where license = :license;';
  709. $license = Yii::app()->db->createCommand($sql)->queryAll(true,array(':license'=>$data['license']));
  710. if (empty($data) || $data == false || count($license) > 1) {
  711. // return '营业执照信息已经存在';
  712. }
  713. if (empty($data['bank_branch'])) {
  714. $res = '请完善结算银行卡信息';
  715. return $res;
  716. }
  717. $data['merchant_type'] = 2;
  718. /*if ($data['merchant_type'] > 2 || $data['merchant_type'] < 1) {
  719. return '商户类型不正确!';
  720. }*/
  721. $paramArray = array();
  722. $info = array();
  723. //基本信息
  724. $info['base']['merchantId'] = $data['leshua_id'];
  725. $info['base']['merchantType'] = $data['merchant_type'] == 2 ? 3 : $data['merchant_type'];
  726. $info['base']['mobile'] = $data['mobile'];
  727. $info['base']['merchantName'] = $data['merchant_name'];
  728. $sql1 = 'select * from wx_leshua_pos_province where tag = :tag;';
  729. $provinceData = Yii::app()->db->createCommand($sql1)->queryRow(true,array(':tag'=>$data['province_code']));
  730. if (empty($provinceData) || $provinceData == false) {
  731. return '系统繁忙,请重试2!';
  732. }
  733. $sql2 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  734. $cityData = Yii::app()->db->createCommand($sql2)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  735. if (empty($cityData) || $cityData == false) {
  736. return '系统繁忙,请重试3!';
  737. }
  738. $sql3 = 'select * from wx_leshua_pos_area where area_tag = :area_tag;';
  739. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':area_tag'=>$data['area_code']));
  740. if (empty($areaData) || $areaData == false) {
  741. $sql3 = 'select * from wx_leshua_pos_city where province_tag = :province_tag and city_tag = :city_tag;';
  742. $areaData = Yii::app()->db->createCommand($sql3)->queryRow(true,array(':province_tag'=>$data['province_code'],':city_tag'=>$data['city_code']));
  743. // if (empty($areaData) || $areaData == false) {
  744. // return '系统繁忙,请重试3!';
  745. // }
  746. }
  747. //商户基本信息(base)
  748. $info['base']['province'] = $provinceData['name'];
  749. $info['base']['city'] = $cityData['name'];
  750. $info['base']['area'] = !isset($areaData['name']) || empty($areaData['name']) ? $cityData['name'] : $areaData['name'];//缺地区
  751. $info['base']['address'] = $data['address'];
  752. if (empty($data['license'])) {
  753. $res = '请完善营业执照信息';
  754. return $res;
  755. }
  756. if (empty($data['license_name'])) {
  757. $res = '请完善营业执照信息';
  758. return $res;
  759. }
  760. if (empty($data['license_address'])) {
  761. $res = '请完善营业执照信息';
  762. return $res;
  763. }
  764. if (empty($data['license_start'])) {
  765. $res = '请完善营业执照信息';
  766. return $res;
  767. }
  768. if (empty($data['license_end'])) {
  769. $res = '请完善营业执照信息';
  770. return $res;
  771. }
  772. // if ($data['merchant_type'] == 2){
  773. //企业商户必传
  774. $info['base']['license'] = $data['license'];
  775. $info['base']['licenseFullName'] = $data['license_name'];//缺营业执照注册名称
  776. $info['base']['licenseAddress'] = $data['license_address'];//缺营业执照注册地址
  777. $info['base']['licenseStart'] = $data['license_start'];
  778. $info['base']['licenseEnd'] = $data['license_end'];
  779. // }
  780. if (empty($data['bank_account_type'])) {
  781. $res = '请完善结算银行卡信息';
  782. return $res;
  783. }
  784. if (empty($data['bank_branch'])) {
  785. $res = '请完善结算银行卡信息';
  786. return $res;
  787. }
  788. if (empty($data['bank_unionpay_code'])) {
  789. $res = '请完善结算银行卡信息';
  790. return $res;
  791. }
  792. if (empty($data['bank_holder'])) {
  793. $res = '请完善结算银行卡信息';
  794. return $res;
  795. }
  796. if (empty($data['bank_account'])) {
  797. $res = '请完善结算银行卡信息';
  798. return $res;
  799. }
  800. if (empty($data['bank_phone'])) {
  801. $res = '请完善结算银行卡信息';
  802. return $res;
  803. }
  804. //账户信息
  805. $info['account']['type'] = $data['bank_account_type'];
  806. $info['account']['branch'] = $data['bank_branch'];
  807. $info['account']['unionpay'] = $data['bank_unionpay_code'];
  808. //$info['account']['holder'] = $data['bank_holder'];
  809. $info['account']['cardId'] = $data['bank_account'];
  810. $info['account']['mobile'] = $data['bank_phone'];
  811. //其他信息
  812. // if ($data['merchant_type'] == 2){
  813. //企业商户必传
  814. if ($data['mcc_type'] == 1){
  815. $info['other']['isIndustryDining'] = 1; //餐娱类???
  816. }else{
  817. $info['other']['isIndustryDining'] = 0;
  818. }
  819. // }
  820. $info['other']['oemMerchantMode'] = 0;
  821. $info['other']['preferentialType'] = 0;
  822. $info['other']['uploadToUnionpay'] = 0;
  823. $info['other']['mccCode'] = $data['mcc_code'];
  824. $info['other']['mccType'] = $data['mcc_type'];
  825. //新增
  826. if (empty($data['appid'])) {
  827. $info['other']['publicsignalAppid'] = 'wx2e7e5a2a92bd1efe';
  828. $info['other']['gzhMerchantName'] = '深圳市迅享同城科技有限公司';
  829. } else {
  830. //必须和公众号主体一致(营业执照上公司全称一致)
  831. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  832. if (empty($data['public_pull_name'])) {
  833. if (!empty($data['license_name'])) {
  834. $info['other']['gzhMerchantName'] = $data['license_name'];
  835. } else {
  836. if (!empty($data['merchant_name'])) {
  837. $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  838. }
  839. }
  840. }
  841. //公众号appid(支付)
  842. $info['other']['publicsignalAppid'] = $data['appid'];
  843. }
  844. //公众号授权目录(支付)
  845. $info['other']['publicsignalAuthorizationDirectory'] = 'https://wap-test.lewaimai.com/lewaimaigod/;https://wap-beta.lewaimai.com/lewaimaigod/;https://wap-dev.lewaimai.com/lewaimaigod/;https://wap.lewaimai.com/lewaimaigod/';
  846. //默认关注迅享同城的公众号
  847. $info['other']['publicsignalAppidGZ'] = 'wx2e7e5a2a92bd1efe';
  848. Yii::log('乐刷参数012901:'.json_encode($info));
  849. $newLeshua = new Newleshua();
  850. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  851. $paramArray['version'] = $newLeshua->leshua_agent_version;
  852. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  853. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  854. $params = array();
  855. $res = array('respCode'=>'1','respMsg'=>'失败');
  856. if (empty($data['idcard_front']) || empty($data['idcard_back'])) {
  857. $res['respMsg'] = '缺少身份证照片';
  858. return $res;
  859. }
  860. if (empty($data['bankcard_front'])) {
  861. $res['respMsg'] = '缺少银行卡照片';
  862. return $res;
  863. }
  864. if (empty($data['business_license_c'])) {
  865. $res['respMsg'] = '缺少公司营业执照照片';
  866. return $res;
  867. }
  868. if (empty($data['business_inside_c'])) {
  869. $res['respMsg'] = '缺少经营场所内设照片';
  870. return $res;
  871. }
  872. if (empty($data['business_door_c'])) {
  873. $res['respMsg'] = '缺少门头照片';
  874. return $res;
  875. }
  876. if (empty($data['business_cashier_desk_c'])) {
  877. $res['respMsg'] = '缺少收银台招盘照';
  878. return $res;
  879. }
  880. if (empty($data['lease_property_c'])) {
  881. $res['respMsg'] = '缺少租赁协议或房产证明照';
  882. return $res;
  883. }
  884. // if ($data['merchant_type'] == 2){
  885. //企业号需传证照
  886. $params['idcardFrontPic'] = IMAGEDOMAIN.$data['idcard_front'];
  887. $params['idcardBackPic'] = IMAGEDOMAIN.$data['idcard_back'];
  888. $params['bankCardFrontPic'] = IMAGEDOMAIN.$data['bankcard_front'];
  889. $params['licensePic'] = IMAGEDOMAIN.$data['business_license_c'];
  890. $params['insidePic'] = IMAGEDOMAIN.$data['business_inside_c'];//缺经营场所内设照片
  891. $params['doorPic'] = IMAGEDOMAIN.$data['business_door_c'];//缺门头照
  892. $params['cashierDeskPic'] = IMAGEDOMAIN.$data['business_cashier_desk_c'];//缺收银台招盘照
  893. $params['agreementPic'] = IMAGEDOMAIN.$data['lease_property_c'];//租赁协议或房产证明图片
  894. // }
  895. $paramArray['data'] = json_encode($info);
  896. Yii::log('editLeshuaAccount paramArray:'.json_encode($paramArray));
  897. Yii::log('editLeshuaAccount paramArray:'.json_encode($params));
  898. LewaimaiDebug::LogArray($paramArray);
  899. LewaimaiDebug::LogArray($params);
  900. LewaimaiDebug::LogArray($newLeshua->leshua_agent_update_url);
  901. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_update_url, $paramArray, $params);
  902. LewaimaiDebug::LogArray($result);
  903. Yii::log('乐刷参数调试0129:'.$result);
  904. Yii::log('result:'.$result);
  905. $res = json_decode($result,true);
  906. return $res;
  907. }
  908. /**
  909. * 修改乐刷信息
  910. * @Author wulingao
  911. * @DateTime 2017-10-17
  912. * @param [type] $id [description]
  913. * @return [type] [description]
  914. */
  915. public static function editLeshuaAccount2($id)
  916. {
  917. if (!isset($id) || empty($id)){
  918. return '该客户不存在!';
  919. }
  920. $sql = 'select * from wx_leshua_apply where id = :id;';
  921. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  922. if (empty($data) || $data == false) {
  923. return '系统繁忙,请重试!';
  924. }
  925. $paramArray = array();
  926. $info = array();
  927. //基本信息
  928. $info['base']['merchantId'] = $data['leshua_id'];
  929. $info['base']['mobile'] = $data['mobile'];
  930. // $info['account']['type'] = $data['bank_account_type'];
  931. // $info['account']['branch'] = $data['bank_branch'];
  932. // $info['account']['unionpay'] = $data['bank_unionpay_code'];
  933. // $info['account']['holder'] = $data['bank_holder'];
  934. // $info['account']['cardId'] = $data['bank_account'];
  935. // $info['account']['mobile'] = $data['bank_phone'];
  936. $newLeshua = new Newleshua();
  937. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  938. $paramArray['version'] = $newLeshua->leshua_agent_version;
  939. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  940. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  941. $params = array();
  942. $paramArray['data'] = json_encode($info);
  943. Yii::log('editLeshuaAccount2 paramArray:'.json_encode($paramArray));
  944. Yii::log('editLeshuaAccount2 paramArray:'.json_encode($params));
  945. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_update_url, $paramArray, $params);
  946. Yii::log('result:'.$result);
  947. $res = json_decode($result,true);
  948. return $res;
  949. }
  950. /**
  951. * 设置商户费率
  952. * @Author wulingao
  953. * @DateTime 2017-10-17
  954. * @param [type] $merchantId [description]
  955. * @return [type] [description]
  956. */
  957. public static function openFee($merchantId, $zhifubao_rate = 60, $weixin_rate = 60){
  958. $newLeshua = new Newleshua();
  959. $paramArray = array();
  960. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  961. $paramArray['version'] = $newLeshua->leshua_agent_version;
  962. //开通扫码支付
  963. //$saomaParamString = '{"merchantId":"'.$merchantId.'","fee":{"openType":1,"T0":"0","weixin":{"t1":{"rate":'.$weixin_rate.'},"t0":{"rate":'.$weixin_rate.'}},"alipay":{"t1":{"rate":'.$zhifubao_rate.'},"t0":{"rate":'.$zhifubao_rate.'}}}}';
  964. $info['merchantId'] = $merchantId;
  965. $info['fee']['openType'] = 1;//1.开通扫码支付(微信和支付宝支付)3.pos 刷卡(card)4.银联扫码(unionScan)
  966. $info['fee']['weixin']['t1']['rate'] = $weixin_rate;
  967. $info['fee']['alipay']['t1']['rate'] = $zhifubao_rate;
  968. Yii::log('扫码支付明文参数:'.json_encode($info));
  969. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  970. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  971. $paramArray['data'] = json_encode($info);
  972. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_open_url, $paramArray);
  973. Yii::log('paramArray:'.json_encode($paramArray));
  974. Yii::log('扫码支付result:'.$result);
  975. // var_dump('开通扫码支付:'.$result);
  976. $result = json_decode($result, true);
  977. if (!isset($result['respCode']) || $result['respCode'] != '000000') {
  978. return '设置费率失败,请重新设置费率1';
  979. }
  980. //开通快捷支付
  981. // $fastpayParamString = '{"fee":{"openType":2,"T0":"0","merchantId":"'.$merchantId.'","fastpay":{"t1Credit":{"rate":70},"t1Debit":{"rate":60,"maxCharge":30000000},"t1OverSee":{"rate":300},"t0Credit":{"rate":70},"t0Debit":{"rate":60,"fixedCharge":2000000},"t0OverSee":{"rate":300}}}}';
  982. // $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  983. // $paramArray['sign'] = $newLeshua->getLeshuaSign(json_decode($fastpayParamString,true));
  984. // $paramArray['data'] = $fastpayParamString;
  985. // $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_open_url, $paramArray);
  986. // Yii::log('paramArray:'.json_encode($paramArray));
  987. // var_dump('开通快捷支付:'.$result);
  988. // $result = json_decode($result, true);
  989. // if (!isset($result['respCode']) || $result['respCode'] != '000000') {
  990. // return '设置费率失败,请重新设置费率2';
  991. // }
  992. //开通pos支付
  993. /*$pospayParamString = '{"fee":{"openType":3,"T0":"0","merchantId":"'.$merchantId.'","card":{"t1Credit":{"rate":70},"t1Debit":{"rate":60,"maxCharge":30000000},"t1OverSee":{"rate":300},"t0Credit":{"rate":70},"t0Debit":{"rate":60,"maxCharge":30000000,"fixedCharge":2000000},"t0OverSee":{"rate":320}}}}';
  994. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  995. $paramArray['sign'] = $newLeshua->getLeshuaSign(json_decode($pospayParamString,true));
  996. $paramArray['data'] = $pospayParamString;
  997. $result = $newLeshua->curl_custom_postfields($newLeshua->leshua_agent_open_url, $paramArray);
  998. Yii::log('paramArray:'.json_encode($paramArray));
  999. Yii::log('result:'.$result);
  1000. // var_dump('开通pos支付:'.$result);
  1001. $result = json_decode($result, true);
  1002. if (!isset($result['respCode']) || $result['respCode'] != '000000') {
  1003. return '设置费率失败,请重新设置费率3';
  1004. }*/
  1005. return true;
  1006. }
  1007. public static function TestgetMerchantInfo($merchantId){
  1008. $newLeshua = new Newleshua();
  1009. $paramArray = array();
  1010. $info = array();
  1011. $info['merchantId'] = $merchantId;
  1012. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  1013. $paramArray['version'] = $newLeshua->leshua_agent_version;
  1014. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  1015. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  1016. $paramArray['data'] = json_encode($info);
  1017. // $result = LewaimaiHttp::POST('http://pos.yeahka.com/api/merchant/get.do',$paramArray);
  1018. // $result = LewaimaiHttp::POST('https://saas.yeahka.com/api/merchant/info_qry',$paramArray);
  1019. $result = LewaimaiHttp::POST('https://saas-mch.leshuazf.comapi/merchant/info_qry',$paramArray);
  1020. Yii::log('查询信息结果3333'.$result);
  1021. $resultArr = json_decode($result,true);
  1022. if ($resultArr['respCode'] == '000000' && $resultArr['respMsg'] =='成功' && isset($resultArr['data'])){
  1023. return $resultArr['data'];
  1024. }else{
  1025. return false;
  1026. }
  1027. }
  1028. /**
  1029. * 提交进件信息到乐刷服务器
  1030. * @Author wulingao
  1031. * @DateTime 2017-10-17
  1032. * @param [type] $url [description]
  1033. * @param array $assoc [description]
  1034. * @param array $files [description]
  1035. * @return [type] [description]
  1036. */
  1037. private function curl_custom_postfields($url, array $assoc = array(), array $files = array())
  1038. {
  1039. static $disallow = array("\0", "\"", "\r", "\n");
  1040. foreach ($assoc as $k => $v) {
  1041. $k = str_replace($disallow, "_", $k);
  1042. $body[] = implode("\r\n", array(
  1043. "Content-Disposition: form-data; name=\"{$k}\"",
  1044. "",
  1045. filter_var($v),
  1046. ));
  1047. }
  1048. if (!empty($files)) {
  1049. foreach ($files as $k => $v) {
  1050. $data = file_get_contents($v);
  1051. // $v = call_user_func("end", explode(DIRECTORY_SEPARATOR, $v));
  1052. $k = str_replace($disallow, "_", $k);
  1053. $v = str_replace($disallow, "_", $v);
  1054. $body[] = implode("\r\n", array(
  1055. "Content-Disposition: form-data; name=\"media\"; filename=\"{$v}\"",
  1056. "Content-Type: application/octet-stream",
  1057. "",
  1058. $data,
  1059. ));
  1060. }
  1061. }
  1062. do {
  1063. $boundary = "---------------------" . md5(mt_rand() . microtime());
  1064. } while (preg_grep("/{$boundary}/", $body));
  1065. // add boundary for each parameters
  1066. array_walk($body, function (&$part) use ($boundary) {
  1067. $part = "--{$boundary}\r\n{$part}";
  1068. });
  1069. // add final boundary
  1070. $body[] = "--{$boundary}--";
  1071. $body[] = "";
  1072. $ch1 = curl_init ();
  1073. // $newLeshua = new Newleshua();
  1074. curl_setopt ( $ch1, CURLOPT_URL, $url);
  1075. curl_setopt ( $ch1, CURLOPT_POST, 1 );
  1076. curl_setopt ( $ch1, CURLOPT_RETURNTRANSFER, 1 );
  1077. curl_setopt ( $ch1, CURLOPT_CONNECTTIMEOUT, 30 );
  1078. curl_setopt ( $ch1, CURLOPT_SSL_VERIFYPEER, FALSE );
  1079. curl_setopt ( $ch1, CURLOPT_SSL_VERIFYHOST, false );
  1080. Yii::log('curl_custom_postfields:'.json_encode($body));
  1081. // set options
  1082. @curl_setopt_array($ch1, array(
  1083. CURLOPT_POST => true,
  1084. CURLOPT_POSTFIELDS => implode("\r\n", $body),
  1085. CURLOPT_HTTPHEADER => array(
  1086. "Expect: 100-continue",
  1087. "Content-Type: multipart/form-data; boundary={$boundary}", // change Content-Type
  1088. ),
  1089. ));
  1090. $result = curl_exec ( $ch1 );
  1091. if(!$result){
  1092. Yii::log('curl_error0221:'.curl_error($ch1));
  1093. }
  1094. curl_close ( $ch1 );
  1095. return $result;
  1096. }
  1097. /**
  1098. * 修改乐刷商户微信和支付宝的费率111
  1099. * @Author wulingao
  1100. * @DateTime 2017-10-17
  1101. * @param [type] $id [description]
  1102. * @return [type] [description]
  1103. */
  1104. public static function editMerchantInfo($id)
  1105. {
  1106. $sql = 'select * from wx_leshua_apply where id = :id;';
  1107. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  1108. if (empty($data) || $data == false) {
  1109. return '系统繁忙,请重试!';
  1110. }
  1111. $newLeshua = new Newleshua();
  1112. $info = array();
  1113. $paramArray = array();
  1114. $info['merchantId'] = $data['leshua_id'];
  1115. $info['fee']['openType'] = $data['open_type'];//1.开通扫码支付(微信和支付宝支付)3.pos 刷卡(card)4.银联扫码(unionScan)
  1116. if($data['open_type']==1){
  1117. $info['fee']['weixin']['t1']['rate'] = $data['weixin_commission_updating']*10000;
  1118. $info['fee']['alipay']['t1']['rate'] = $data['zhifubao_commission_updating']*10000;
  1119. }elseif($data['open_type']==3){
  1120. $info['fee']['card']['t1Credit']['rate'] = $data['weixin_commission_updating']*10000;
  1121. $info['fee']['card']['t1Debit']['rate'] = $data['zhifubao_commission_updating']*10000;
  1122. $info['fee']['card']['t1OverSee']['rate'] = $data['zhifubao_commission_updating']*10000;
  1123. }elseif($data['open_type']==4){
  1124. $info['fee']['unionScan']['t1Credit']['rate'] = $data['weixin_commission_updating']*10000;
  1125. $info['fee']['unionScan']['t1Debit']['rate'] = $data['zhifubao_commission_updating']*10000;
  1126. $info['fee']['unionScan']['t1OverSee']['rate'] = $data['zhifubao_commission_updating']*10000;
  1127. }
  1128. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  1129. $paramArray['version'] = $newLeshua->leshua_agent_version;
  1130. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  1131. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  1132. $paramArray['data'] = json_encode($info);
  1133. $result = LewaimaiHttp::POST($newLeshua->leshua_agent_open_url,$paramArray);
  1134. Yii::log('修改结果413122'.$result);
  1135. $resultArr = json_decode($result,true);
  1136. if ($resultArr['respCode'] == '000000' && $resultArr['respMsg'] =='成功'){
  1137. return true;
  1138. }else{
  1139. return false;
  1140. }
  1141. }
  1142. /**
  1143. * 修改商户信息接口
  1144. * @param $id
  1145. * @return bool|string
  1146. */
  1147. public static function updateMerchantInfo($id)
  1148. {
  1149. $sql = 'select * from wx_leshua_apply where id = :id;';
  1150. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  1151. if (empty($data) || $data == false) {
  1152. return '系统繁忙,请重试!';
  1153. }
  1154. $newLeshua = new Newleshua();
  1155. $info = array();
  1156. $paramArray = array();
  1157. $info['base']['merchantId'] = $data['leshua_id'];
  1158. $info['account']['branch'] = $data['bank_branch'];
  1159. // //新增
  1160. // //必须和公众号主体一致(营业执照上公司全称一致)
  1161. // $info['other']['gzhMerchantName'] = $data['public_pull_name'];
  1162. // //公众号appid(支付)
  1163. // $info['other']['publicsignalAppid'] = $data['appid'];
  1164. /*$info['fee']['openType'] = $data['open_type'];//1.开通扫码支付(微信和支付宝支付)2.开通快捷支付
  1165. $info['fee']['weixin']['t1']['rate'] = $data['weixin_commission_updating']*10000;
  1166. $info['fee']['weixin']['t0']['rate'] = $data['weixin_commission_updating']*10000;
  1167. $info['fee']['alipay']['t1']['rate'] = $data['zhifubao_commission_updating']*10000;
  1168. $info['fee']['alipay']['t0']['rate'] = $data['zhifubao_commission_updating']*10000;
  1169. $info['fee']['merchantId'] = $data['leshua_id'];*/
  1170. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  1171. $paramArray['version'] = $newLeshua->leshua_agent_version;
  1172. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  1173. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  1174. $paramArray['data'] = json_encode($info);
  1175. //var_dump(json_encode($info));die;
  1176. $result = LewaimaiHttp::POST($newLeshua->leshua_agent_update_url,$paramArray);
  1177. Yii::log('修改结果413122'.$result);
  1178. $resultArr = json_decode($result,true);
  1179. return $resultArr;
  1180. if ($resultArr['respCode'] == '000000' && $resultArr['respMsg'] =='成功'){
  1181. Yii::log(66668886666888);
  1182. return true;
  1183. }else{
  1184. return false;
  1185. }
  1186. }
  1187. /**
  1188. * 设置商户支付信息
  1189. * @param $id
  1190. * @return bool|string
  1191. */
  1192. public static function setMerchantPayInfo($data)
  1193. {
  1194. $newLeshua = new Newleshua();
  1195. $info = array();
  1196. $paramArray = array();
  1197. $info = $data;
  1198. /*$info['merchantId'] = $data['merchantID'];
  1199. $info['configType'] = $data['configType'];
  1200. $info['sub_appid'] = $data['sub_appid'];
  1201. if(isset($data['subscribe_appid'])){
  1202. $info['subscribe_appid'] = $data['subscribe_appid'];
  1203. }*/
  1204. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  1205. $paramArray['version'] = $newLeshua->leshua_agent_version;
  1206. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  1207. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  1208. $paramArray['data'] = json_encode($info);
  1209. $result = LewaimaiHttp::POST($newLeshua->leshua_agent_update_url,$paramArray);
  1210. Yii::log('设置支付参数结果'.$result);
  1211. $resultArr = json_decode($result,true);
  1212. if ($resultArr['respCode'] == '000011' && $resultArr['respMsg'] =='成功'){
  1213. Yii::log(66668886666888);
  1214. return true;
  1215. }else{
  1216. return false;
  1217. }
  1218. }
  1219. //查询乐刷商户信息
  1220. public static function getMerchantInfo($id)
  1221. {
  1222. $sql = 'select * from wx_leshua_apply where id = :id;';
  1223. $data = Yii::app()->db->createCommand($sql)->queryRow(true,array(':id'=>$id));
  1224. if (empty($data) || $data == false) {
  1225. return '系统繁忙,请重试!';
  1226. }
  1227. $newLeshua = new Newleshua();
  1228. $paramArray = array();
  1229. $info = array();
  1230. $info['merchantId'] = $data['leshua_id'];
  1231. $paramArray['agentId'] = $newLeshua->leshua_agent_id;
  1232. $paramArray['version'] = $newLeshua->leshua_agent_version;
  1233. $paramArray['reqSerialNo'] = $newLeshua->getreqSerialNo();
  1234. $paramArray['sign'] = $newLeshua->getLeshuaSign($info);
  1235. $paramArray['data'] = json_encode($info);
  1236. $result = LewaimaiHttp::POST($newLeshua->leshua_wxpayconfig_qry_url,$paramArray);
  1237. Yii::log('查询信息结果3333'.$result);
  1238. $resultArr = json_decode($result,true);
  1239. if ($resultArr['respCode'] == '000000' && $resultArr['respMsg'] =='成功' && isset($resultArr['data'])){
  1240. return $resultArr['data'];
  1241. }else{
  1242. return false;
  1243. }
  1244. }
  1245. //获取签名
  1246. private function getLeshuaSign($paramArray)
  1247. {
  1248. $sign = base64_encode(md5('lepos'.$this->leshua_agent_key.json_encode($paramArray)));
  1249. Yii::log('qianming:'.$sign);
  1250. return $sign;
  1251. }
  1252. private function getreqSerialNo()
  1253. {
  1254. $date = date('Ymd');
  1255. $strNo = '00000001';
  1256. //unset(Yii::app()->session['req_serial_no_num']);
  1257. if (isset(Yii::app()->session['req_serial_no_num'])){
  1258. $strNo = Yii::app()->session['req_serial_no_num'];
  1259. $num = intval($strNo);
  1260. $num += 1;
  1261. $length = strlen($num);
  1262. $finaLength = 8-$length;
  1263. if ($finaLength > 0){
  1264. for ( $i = 0;$i < $finaLength;$i++){
  1265. $num = '0'.$num;
  1266. }
  1267. }
  1268. $strNo = $num;
  1269. }
  1270. Yii::app()->session['req_serial_no_num'] = $strNo;
  1271. $reqSerialNo = $date.$strNo;
  1272. return $reqSerialNo;
  1273. }
  1274. }