Test.Class.php 127 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707
  1. <?php
  2. /**
  3. * 测试
  4. * Created by PhpStorm.
  5. * User=> 小威
  6. * Date=> 2020/05/16
  7. * Time=> 11=>31
  8. */
  9. namespace Jindouyun\Controller\Common;
  10. use JinDouYun\Cache\SkuCache;
  11. use JinDouYun\Cache\Stock;
  12. use JinDouYun\Dao\Customer\DCustomer;
  13. use JinDouYun\Dao\Goods\DGoods;
  14. use JinDouYun\Dao\GoodsCategory\DGoodsCategory;
  15. use JinDouYun\Dao\GoodsManage\DGoodsBasic;
  16. use JinDouYun\Dao\GoodsManage\DGoodsBrand;
  17. use JinDouYun\Dao\GoodsManage\DSku;
  18. use JinDouYun\Dao\GoodsManage\DUnits;
  19. use JinDouYun\Dao\Market\DUserCoupon;
  20. use JinDouYun\Model\Customer\MCustomer;
  21. use JinDouYun\Model\Enterprise\MEnterprise;
  22. use JinDouYun\Model\Finance\MReceive;
  23. use Jindouyun\Model\Finance\MPay;
  24. use JinDouYun\Model\Goods\MGoods;
  25. use JinDouYun\Model\Goods\MQuickGoods;
  26. use JinDouYun\Model\MBaseModel;
  27. use JinDouYun\Model\GoodsManage\MGoodsBasic;
  28. use JinDouYun\Model\Order\MOrder;
  29. use JinDouYun\Model\System\MModule;
  30. use Mall\Framework\Core\ErrorCode;
  31. use Mall\Framework\Cache\Redis;
  32. use Mall\Framework\Core\ResultWrapper;
  33. use Mall\Framework\Core\StatusCode;
  34. use Mall\Framework\Factory;
  35. use Util\KuaiDi100\Query;
  36. use Util\WeiXin\Offiaccount;
  37. use Util\WeiXin\Miniprogram;
  38. use Util\WeiXin\Pay;
  39. use Util\KeRuYun\Open;
  40. use Util\DaDa\Merchant;
  41. class Test
  42. {
  43. public function index()
  44. {
  45. $objStock = new Stock(64);
  46. $a = $objStock->createSerialSn(0, 'Order');
  47. echo $a;
  48. die;
  49. }
  50. public function getModuleNameByUri()
  51. {
  52. $objMModule = new MModule();
  53. $objMModule->getModuleNameByUri('GoodsManage/GoodsBasic/getGoodsBasicInfoById');
  54. }
  55. private $objDGoods;
  56. /**
  57. * @var Redis
  58. */
  59. private $cache;
  60. /**
  61. * @var string
  62. */
  63. private $delayQueueCancelOrderKey = 'delay_queue_cancel_order';
  64. public function test()
  65. {
  66. exit(json_encode([
  67. 'state' => true,
  68. 'data' => '0.30kg',
  69. 'errorMsg' => '',
  70. ]));
  71. }
  72. /**
  73. * Doc: (des="")
  74. * User: XMing
  75. * Date: 2020/9/23
  76. * Time: 5:04 下午
  77. * @throws \Exception
  78. */
  79. public function pushDelay()
  80. {
  81. $this->cache = Factory::cache('default');
  82. $res = $this->cache->zAdd($this->delayQueueCancelOrderKey . '::1', time(), 100);
  83. //$orderIds = $this->cache->zrangebyscore($this->delayQueueCancelOrderKey.'::1', 0, time()-60, ['withscores' => TRUE]);
  84. //print_r($orderIds);die;
  85. //$res = $this->cache->zrem($this->delayQueueCancelOrderKey.'::1', 100);
  86. var_dump($res);
  87. }
  88. /**
  89. * Doc: (des="注册补发优惠券")
  90. * User: XMing
  91. * Date: 2020/9/22
  92. * Time: 11:57 上午
  93. */
  94. public function couponRegister()
  95. {
  96. self::coupon([
  97. 'userCenterId' => '',
  98. 'customerId' => '',
  99. 'enterpriseId' => '',
  100. ], 'MRegisterCoupon');
  101. }
  102. public function codeTest()
  103. {
  104. $location = 'eyJwcm92aW5jZU5hbWUiOiLlub/kuJznnIEiLCJjaXR5TmFtZSI6IuS4nOiOnuW4giIsImRpc3RyaWN0TmFtZSI6W10sImFkZHJlc3MiOiLkuK3lm73nn7PljJbkuJzojp7luILpobrovr7liqDmsrnnq5npmYTov5EiLCJsYXRpdHVkZSI6MjMuMDIyMTM1LCJsb25naXR1ZGUiOjExMy43MjI5NzR9';
  105. $areaArr = json_decode(base64_decode($location), true);
  106. V($areaArr);
  107. }
  108. /**
  109. * 营销活动(领取优惠券)
  110. * @param $data
  111. * @param $className
  112. */
  113. protected static function coupon($data, $className)
  114. {
  115. $i = 1;
  116. do {
  117. $postData = [
  118. 'topicName' => 'MyJob',
  119. 'topicClass' => "Jobs\Model\MTopic\Market\\" . $className,
  120. 'topicMethon' => 'push',
  121. 'topicMethonParams' => [
  122. 'userCenterId' => $data['userCenterId'],
  123. 'enterpriseId' => $data['enterpriseId'],
  124. 'customerId' => $data['customerId'],
  125. 'payAmount' => isset($data['payAmount']) ? $data['payAmount'] : 0,
  126. ],
  127. ];
  128. $url = QIANNIAO_QUEUE . '/CAddJob/add';
  129. $result = request($url, $postData);
  130. print_r($result);
  131. $i++;
  132. } while ($result['httpcode'] != 200 && $i <= 3);
  133. }
  134. /*******************************
  135. * @var string
  136. *
  137. *
  138. * * es-----------------------ip----------------记得换
  139. * * es-----------------------ip----------------记得换
  140. * * es-----------------------ip----------------记得换
  141. * * es-----------------------ip----------------记得换
  142. * * es-----------------------ip----------------记得换
  143. * * es-----------------------ip----------------记得换
  144. * * es-----------------------ip----------------记得换
  145. * * es-----------------------ip----------------记得换
  146. * * es-----------------------ip----------------记得换
  147. * * es-----------------------ip----------------记得换
  148. * * es-----------------------ip----------------记得换
  149. * * es-----------------------ip----------------记得换
  150. * * es-----------------------ip----------------记得换
  151. * * es-----------------------ip----------------记得换
  152. * * es-----------------------ip----------------记得换
  153. * * es-----------------------ip----------------记得换
  154. * * es-----------------------ip----------------记得换
  155. * * es-----------------------ip----------------记得换
  156. * * es-----------------------ip----------------记得换
  157. * * es-----------------------ip----------------记得换
  158. * * es-----------------------ip----------------记得换
  159. * * es-----------------------ip----------------记得换
  160. * * es-----------------------ip----------------记得换
  161. * * es-----------------------ip----------------记得换
  162. * * es-----------------------ip----------------记得换
  163. * * es-----------------------ip----------------记得换
  164. * * es-----------------------ip----------------记得换
  165. * * es-----------------------ip----------------记得换
  166. * * es-----------------------ip----------------记得换
  167. * * es-----------------------ip----------------记得换
  168. * * es-----------------------ip----------------记得换
  169. * * es-----------------------ip----------------记得换
  170. * * es-----------------------ip----------------记得换
  171. * * es-----------------------ip----------------记得换
  172. * * es-----------------------ip----------------记得换
  173. * * es-----------------------ip----------------记得换
  174. * * es-----------------------ip----------------记得换
  175. * * es-----------------------ip----------------记得换
  176. * * es-----------------------ip----------------记得换
  177. * * es-----------------------ip----------------记得换
  178. * * es-----------------------ip----------------记得换
  179. * * es-----------------------ip----------------记得换
  180. * * es-----------------------ip----------------记得换
  181. * * es-----------------------ip----------------记得换
  182. * * es-----------------------ip----------------记得换
  183. * * es-----------------------ip----------------记得换
  184. * * es-----------------------ip----------------记得换
  185. * * es-----------------------ip----------------记得换
  186. * * es-----------------------ip----------------记得换
  187. * * es-----------------------ip----------------记得换
  188. * * es-----------------------ip----------------记得换
  189. * * es-----------------------ip----------------记得换
  190. * * es-----------------------ip----------------记得换
  191. * * es-----------------------ip----------------记得换
  192. * * es-----------------------ip----------------记得换
  193. * * es-----------------------ip----------------记得换
  194. * * es-----------------------ip----------------记得换
  195. * * es-----------------------ip----------------记得换
  196. * * es-----------------------ip----------------记得换
  197. * * es-----------------------ip----------------记得换
  198. * * es-----------------------ip----------------记得换
  199. * * es-----------------------ip----------------记得换
  200. *
  201. *
  202. *
  203. *
  204. *
  205. *
  206. *
  207. *
  208. *
  209. *
  210. *
  211. *
  212. * es-----------------------ip----------------记得换
  213. *
  214. *
  215. *
  216. *
  217. *
  218. *
  219. *
  220. *
  221. *
  222. *
  223. *
  224. *
  225. *
  226. *
  227. *
  228. *
  229. *
  230. *
  231. *
  232. *
  233. *
  234. *
  235. *
  236. *
  237. *
  238. *
  239. *
  240. *
  241. *
  242. *
  243. *
  244. *
  245. *
  246. * **/
  247. private $Authorization;
  248. private $Token;
  249. /**
  250. * 格式化导入数据
  251. */
  252. public function formatData()
  253. {
  254. //导入数据需要修改以下6处地方 然后把商品信息和商品数组按照key对应
  255. //1.更换请求头token!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  256. $Authorization = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjI1MTUsImV4cGlyZVRpbWUiOjE2MjU1NjU0MzB9.r1KfvvNgHTTGcFFNNQed22TIB0y0bPLmdwsnh8ksNxg';
  257. $Token = 'a3af5bf6213ac4bc899c6d0a78d1613e';
  258. //2.切换config
  259. //3.切换esip
  260. //4.修改商品图片(去该企业的图片库复制一个合适的图片)
  261. $images = ["https://onlineimg.qianniao.vip/162496878735338/a3af5bf6213ac4bc899c6d0a78d1613e/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20210629200937.jpg"];//商品图片
  262. //5.企业id
  263. $enterpriseId = 308;
  264. //6.多单位
  265. $twoUnit = false;
  266. //获取数据文件
  267. $file = file(PROJECT_PATH.'/Public/www/1.txt');
  268. //引用dao
  269. $objDGoodsCategory = new DGoodsCategory();
  270. $objDGoodsCategory->setTable('qianniao_goods_category_' . $enterpriseId);
  271. $objDGoodsBrand = new DGoodsBrand();
  272. $objDGoodsBrand->setTable('qianniao_goods_brand_' . $enterpriseId);
  273. $objDUnits = new DUnits();
  274. $objDUnits->setTable('qianniao_units_' . $enterpriseId);
  275. //请求地址
  276. $apiUrl = 'https://api.qianniao.vip/Goods/QuickGoods/addBasicAndPublishGoods';
  277. //请求参数
  278. $curl_option = [
  279. CURLOPT_HTTPHEADER => [
  280. 'Content-Type:text/plain',
  281. 'Authorization:'.$Authorization,
  282. 'Token:'.$Token,
  283. ],
  284. ];
  285. $i = 0;
  286. //获取数据
  287. foreach ($file as $value) {
  288. if(!strpos($value,',')){
  289. echo '商品数据格式错误';exit;
  290. }
  291. $goodsArray = explode(',', $value);
  292. //商品信息
  293. $categoryName = isset($goodsArray[0]) ? trim($goodsArray[0]) : '';//分类名称
  294. $brandName = isset($goodsArray[3]) ? trim($goodsArray[3]) : '';//品牌名称
  295. $goodsName = isset($goodsArray[1]) ? trim($goodsArray[1]) : '';//商品名称
  296. $describe = isset($goodsArray[6213]) ? trim($goodsArray[6321]) : '';//商品卖点
  297. $description = isset($goodsArray[110]) ? '<p>' . trim($goodsArray[110]) . '</p>' : '';//商品详情
  298. //主单位信息
  299. $skuName = isset($goodsArray[2]) ? trim($goodsArray[2]) : '无';//单位名称
  300. $barCode = isset($goodsArray[34]) ? trim($goodsArray[43]) : '';//主单位条码
  301. $salePrice = isset($goodsArray[423]) ? trim($goodsArray[432]) : 1;//商品价格
  302. $salePriceTrue = isset($goodsArray[52]) ? trim($goodsArray[53]) : bcmul($salePrice, 1.2, 2);//市场价格
  303. //辅单位信息
  304. if($twoUnit){
  305. $skuNameTwo = isset($goodsArray[56]) ? trim($goodsArray[65]) : '';//辅单位
  306. $barCodeTwo = isset($goodsArray[32]) ? trim($goodsArray[32]) : '';//辅单位条码
  307. $conversion = isset($goodsArray[56]) ? trim($goodsArray[56]) : 0;//辅单位换算比例
  308. $salePriceTwo = isset($goodsArray[65]) ? trim($goodsArray[65]) : 1;//辅单位销售价格
  309. $salePriceTwoTrue = isset($goodsArray[34]) ? trim($goodsArray[34]) : bcmul($salePriceTwo, 1.2, 2);//辅单位市场价格
  310. }
  311. if (empty($goodsName)) {
  312. continue;
  313. }
  314. /***分类数据***/
  315. if (!empty($categoryName)) {
  316. //查询分类是否存在
  317. $categorySelect = [
  318. 'title' => $categoryName,
  319. ];
  320. $dbResult = $objDGoodsCategory->get($categorySelect);
  321. if ($dbResult === false) {
  322. exit($objDGoodsCategory->error());
  323. }
  324. $category = $dbResult;
  325. unset($dbResult);
  326. if (empty($category)) {
  327. $categoryInsert = [
  328. 'sort' => 0,
  329. 'title' => $categoryName,
  330. 'pid' => 0,
  331. 'enableStatus' => StatusCode::$standard,
  332. 'deleteStatus' => StatusCode::$standard,
  333. 'createTime' => time(),
  334. 'updateTime' => time(),
  335. ];
  336. $dbResult = $objDGoodsCategory->insert($categoryInsert);
  337. if ($dbResult === false) {
  338. exit($objDGoodsCategory->error());
  339. }
  340. $categoryId = $dbResult;
  341. $categoryPath = $dbResult;
  342. unset($dbResult);
  343. } else {
  344. $categoryId = $category['id'];
  345. if(!empty($category['link'])){
  346. $categoryPath = $category['link'] . ',' . $category['id'];
  347. }else{
  348. $categoryPath = $category['id'];
  349. }
  350. }
  351. } else {
  352. $categoryId = 1;
  353. $categoryPath = '1';
  354. }
  355. /***品牌数据***/
  356. if (!empty($brandName)) {
  357. //查询品牌是否存在
  358. $brandSelect = [
  359. 'title' => $brandName
  360. ];
  361. $dbResult = $objDGoodsBrand->get($brandSelect);
  362. if ($dbResult === false) {
  363. exit($objDGoodsBrand->error());
  364. }
  365. $brand = $dbResult;
  366. unset($dbResult);
  367. if (empty($brand)) {
  368. $brandInsert = [
  369. 'title' => $brandName,
  370. 'images' => null,
  371. 'sort' => 0,
  372. 'enableStatus' => StatusCode::$standard,
  373. 'createTime' => time(),
  374. 'updateTime' => time(),
  375. ];
  376. $dbResult = $objDGoodsBrand->insert($brandInsert);
  377. if ($dbResult === false) {
  378. exit($objDGoodsBrand->error());
  379. }
  380. $brandId = $dbResult;
  381. unset($dbResult);
  382. } else {
  383. $brandId = $brand['id'];
  384. }
  385. } else {
  386. $brandId = 1;
  387. }
  388. /***单位数据***/
  389. $skuId = NULL;
  390. if (!empty($skuName)) {
  391. //查询单位是否存在
  392. $skuSelect = [
  393. 'unitName' => $skuName
  394. ];
  395. $dbResult = $objDUnits->get($skuSelect);
  396. if ($dbResult === false) {
  397. exit($objDUnits->error());
  398. }
  399. $sku = $dbResult;
  400. unset($dbResult);
  401. if (empty($sku)) {
  402. $skuInsert = [
  403. 'unitName' => $skuName,
  404. 'enableStatus' => StatusCode::$standard,
  405. 'createTime' => time(),
  406. 'updateTime' => time(),
  407. ];
  408. $dbResult = $objDUnits->insert($skuInsert);
  409. if ($dbResult === false) {
  410. exit($objDUnits->error());
  411. }
  412. $skuId = $dbResult;
  413. unset($dbResult);
  414. } else {
  415. $skuId = $sku['id'];
  416. }
  417. }
  418. $skuIdTwo = NULL;
  419. if (!empty($skuNameTwo)) {
  420. //查询单位是否存在
  421. $skuSelect = [
  422. 'unitName' => $skuNameTwo
  423. ];
  424. $dbResult = $objDUnits->get($skuSelect);
  425. if ($dbResult === false) {
  426. exit($objDUnits->error());
  427. }
  428. $sku = $dbResult;
  429. unset($dbResult);
  430. if (empty($sku)) {
  431. $skuInsert = [
  432. 'unitName' => $skuNameTwo,
  433. 'enableStatus' => StatusCode::$standard,
  434. 'createTime' => time(),
  435. 'updateTime' => time(),
  436. ];
  437. $dbResult = $objDUnits->insert($skuInsert);
  438. if ($dbResult === false) {
  439. exit($objDUnits->error());
  440. }
  441. $skuIdTwo = $dbResult;
  442. unset($dbResult);
  443. } else {
  444. $skuIdTwo = $sku['id'];
  445. }
  446. }
  447. if($twoUnit){
  448. $postData = [
  449. "categoryPath" => $categoryPath,
  450. "title" => $goodsName,
  451. "storage" => "",
  452. "delUnitIds" => [],
  453. "delSpecSkuIds" => [],
  454. "specType" => 1,
  455. "specGroup" => [],
  456. "specMultiple" => [
  457. [
  458. "barCode" => $barCode,
  459. "weight" => "",
  460. "isDefault" => 5,
  461. "unitId" => $skuId,
  462. "unitName" => $skuName,
  463. "isMaster" => 5,
  464. "conversion" => 0,
  465. "specImage" => "",
  466. "specGroup" => [],
  467. "salePrice" => [
  468. "conversion" => 0,
  469. "unitName" => $skuName,
  470. "unitId" => $skuId,
  471. "isMaster" => 5,
  472. "deleteStatus" => 5,
  473. "enabledLadder" => 0,
  474. "salePriceAreaType" => 1,
  475. "salePrice" => $salePrice,
  476. "ladderPrice" => [],
  477. "marketPrice" => $salePriceTrue,
  478. "setNum" => 1
  479. ]
  480. ],
  481. [
  482. "barCode" => $barCodeTwo,
  483. "isDefault" => 4,
  484. "unitId" => $skuIdTwo,
  485. "unitName" => $skuNameTwo,
  486. "isMaster" => 4,
  487. "conversion" => $conversion,
  488. "specImage" => "",
  489. "specGroup" => [],
  490. "salePrice" => [
  491. "conversion" => $conversion,
  492. "unitName" => $skuNameTwo,
  493. "unitId" => $skuIdTwo,
  494. "isMaster" => 4,
  495. "deleteStatus" => 5,
  496. "enabledLadder" => 0,
  497. "salePriceAreaType" => 1,
  498. "salePrice" => $salePriceTwo,
  499. "ladderPrice" => [],
  500. "marketPrice" => $salePriceTwoTrue,
  501. "setNum" => 1
  502. ]
  503. ]
  504. ],
  505. "unitData" => [
  506. [
  507. "barCode" => "",
  508. "weight" => "",
  509. "isMaster" => 5,
  510. "isDefault" => 5,
  511. "unitName" => $skuName,
  512. "unitId" => $skuId
  513. ],
  514. [
  515. "unitName" => $skuNameTwo,
  516. "isMaster" => 4,
  517. "unitId" => $skuIdTwo,
  518. "conversion" => $conversion,
  519. "isEditSpec" => 5
  520. ]
  521. ],
  522. "describe" => $describe,
  523. "code" => "",
  524. "barCode" => "",
  525. "weight" => "",
  526. "categoryId" => $categoryId,
  527. "expireTime" => "",
  528. "brandId" => $brandId,
  529. "tag" => "",
  530. "description" => $description,
  531. "noSalesShop" => "",
  532. "images" => $images,
  533. "enableStatus" => 5,
  534. "deliverySupIds" => "1,2",
  535. "expressType" => 1,
  536. "expressFee" => "",
  537. "showExpress" => 5,
  538. "ruleId" => "",
  539. "isStore" => false
  540. ];
  541. }else{
  542. /***插入商品***/
  543. $specMultiple = [[
  544. "barCode" => $barCode,//商品条码
  545. "isDefault" => 5,
  546. "unitId" => $skuId,
  547. "unitName" => $skuName,
  548. "isMaster" => 5,
  549. "conversion" => 0,
  550. "specImage" => "",
  551. "specGroup" => [],
  552. "salePrice" => [
  553. "conversion" => 0,
  554. "unitName" => $skuName,
  555. "unitId" => $skuId,
  556. "isMaster" => 5,
  557. "deleteStatus" => 5,
  558. "enabledLadder" => 0,
  559. "salePriceAreaType" => 1,
  560. "salePrice" => $salePrice,//商品价格
  561. "ladderPrice" => [],
  562. "marketPrice" => $salePriceTrue,
  563. "setNum" => 1//限定数量
  564. ]
  565. ]];
  566. $postData = [
  567. 'categoryPath' => $categoryPath,
  568. 'title' => $goodsName,
  569. 'storage' => '',
  570. 'delUnitIds' => [],
  571. 'delSpecSkuIds' => [],
  572. 'specType' => 1,//1:无规格
  573. 'specGroup' => [],//无规格为空
  574. 'specMultiple' => $specMultiple,
  575. 'unitData' =>
  576. [
  577. [
  578. 'barCode' => '',
  579. 'isMaster' => 5,
  580. 'isDefault' => 5,
  581. 'unitName' => $skuName,
  582. 'unitId' => $skuId,
  583. ],
  584. ],
  585. 'describe' => $describe,//商品卖点
  586. 'code' => '',
  587. 'barCode' => '',
  588. 'categoryId' => $categoryId,
  589. 'expireTime' => '',
  590. 'brandId' => $brandId,
  591. 'tag' => '',
  592. 'description' => $description,//商品详情
  593. 'noSalesShop' => '',
  594. 'images' => $images,
  595. 'enableStatus' => 5,
  596. ];
  597. }
  598. $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
  599. if ($result['httpcode'] != 200) {
  600. exit($result['content']);
  601. }
  602. $content = json_decode($result['content'], true);
  603. if ($content['state'] == false) {
  604. exit($content['data']);
  605. }
  606. $i++;
  607. var_dump('导入成功:'.$goodsName);
  608. // break;
  609. }
  610. exit('执行成功, 共添加' . $i . '条数据');
  611. }
  612. /**
  613. * 导入
  614. * 批量添加客户
  615. */
  616. public function autoAddCustomer()
  617. {
  618. $apiUrl = 'http://api.qianniao.vip/Customer/Customer/addCustomer';
  619. $curl_option = [
  620. CURLOPT_HTTPHEADER => [
  621. 'Content-Type:text/plain',
  622. 'Authorization:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjMxMDEsImV4cGlyZVRpbWUiOjE2MDY0NTMxMjB9.gSDdfi4e0Hx_XIE-mGNRB7Ehk0iOclzpsQCv6P3ysXE',
  623. 'Token:95619f5cc272439f87d9b0e6b87be3e4',
  624. ],
  625. ];
  626. $file = file('./1.txt');
  627. foreach ($file as $key => $value) {
  628. $array = explode(',', $value);
  629. $customerName = isset($array[0]) ? trim($array[0]) : '';//客户名称
  630. $mobile = isset($array[1]) ? trim($array[1]) : '';//手机号
  631. $remark = isset($array[2]) ? trim($array[2]) : '';//备注
  632. $shopId = '';//商铺id
  633. $type = 35;//客户类型id
  634. if (empty($mobile)) {
  635. continue;
  636. }
  637. // if(empty($mobile) || strlen($mobile) != 11){
  638. // $len = 4 - strlen($key + 1);
  639. // $str = '';
  640. // for($i = 1; $i <= $len; $i++){
  641. // $str .= '0';
  642. // }
  643. // $mobile = '1111111'.$str.($key + 1);
  644. // }
  645. $postData = array(
  646. 'tempSave' => '',
  647. 'latitude' => '',
  648. 'longitude' => '',
  649. 'password' => '',
  650. 'area' => '',
  651. 'mobile' => $mobile,
  652. 'enableStatus' => 5,
  653. 'name' => $customerName,
  654. 'code' => '',
  655. 'type' => $type,
  656. 'provinceCode' => 610000,
  657. 'cityCode' => 610100,
  658. 'districtCode' => 610112,
  659. 'address' => '',
  660. 'managerMobile' => '',
  661. 'shopId' => $shopId,
  662. 'departmentId' => '',
  663. 'salesManId' => '',
  664. 'salesManCode' => '',
  665. 'salesManName' => '',
  666. 'birthday' => 0,
  667. 'remark' => $remark,
  668. 'extend' =>
  669. array(
  670. 'license' => '',
  671. ),
  672. 'contact' =>
  673. array(
  674. 'area' => '',
  675. 'name' => $customerName,
  676. 'mobile' => $mobile,
  677. 'provinceCode' => 610000,
  678. 'cityCode' => 610100,
  679. 'districtCode' => 610112,
  680. 'address' => '大明宫万达',
  681. ),
  682. );
  683. $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
  684. if ($result['httpcode'] != 200) {
  685. exit($result['content']);
  686. }
  687. $content = json_decode($result['content'], true);
  688. if ($content['state'] == false) {
  689. // exit($content['data']);
  690. }
  691. }
  692. }
  693. public function enterpriseId97ByTime0907()
  694. {
  695. //获取数据
  696. $file = file('./enterpriseId97ByTime0907.txt');
  697. //循环数据
  698. $goodsData = [];
  699. foreach ($file as $value) {
  700. //格式化商品数据
  701. $goodsArray = explode(',', $value);
  702. $goods['id'] = trim($goodsArray[0]);//商品ID
  703. $goods['name'] = trim($goodsArray[1]);//商品名称
  704. $goods['spec'] = [trim($goodsArray[2])];//商品规格
  705. $goods['category'] = trim($goodsArray[3]);//商品分类
  706. $goods['price'] = trim($goodsArray[4]);//商品价格
  707. if (!strripos($goods['category'], " ")) {
  708. continue;
  709. }
  710. if (isset($goodsData[$goods['id']])) {
  711. $goodsData[$goods['id']]['spec'] = array_merge($goodsData[$goods['id']]['spec'], $goods['spec']);
  712. } else {
  713. $goodsData[$goods['id']] = $goods;
  714. }
  715. }
  716. unset($goodsArray);
  717. unset($goods);
  718. // V($goodsData);
  719. //查询所有分类
  720. $sql = 'select id,link,title from qianniao_goods_category_97';
  721. $dbResult = $this->objDGoods->query($sql);
  722. if ($dbResult === false) {
  723. exit($this->objDGoods->error());
  724. }
  725. //格式化分类
  726. $categoryData = [];
  727. foreach ($dbResult as $value) {
  728. $categoryData[$value['title']] = [
  729. 'id' => $value['id'],
  730. 'path' => empty($value['link']) ? $value['id'] : $value['link'] . ',' . $value['id']
  731. ];
  732. }
  733. //请求数据
  734. $apiUrl = 'http://api.qianniao.vip/Goods/QuickGoods/addBasicAndPublishGoods';
  735. $curl_option = [
  736. CURLOPT_HTTPHEADER => [
  737. 'Content-Type:text/plain',
  738. 'Authorization:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjIxMDgsImV4cGlyZVRpbWUiOjE1OTk0Njc5ODN9.gG5Ike-xmmKqe-_CpE5tVbSIESvU7-2AlfTlK-ouLNI',
  739. 'Token:4c8574ddcbf69ea23bcf403c0b0830e9'
  740. ],
  741. ];
  742. $specApiUrl = 'http://api.qianniao.vip/GoodsManage/SpecManage/defineSpec';
  743. $i = 0;
  744. foreach ($goodsData as $value) {
  745. //区分有没有规格
  746. $specType = 1;//无规格
  747. $specGroup = [];//无规格
  748. $specMultipleNo = [];
  749. $specMultipleNo[] = [
  750. "barCode" => "",
  751. "isDefault" => 5,
  752. "unitId" => 1,
  753. "unitName" => "件",
  754. "isMaster" => 5,
  755. "conversion" => 0,
  756. "specImage" => "",
  757. "specGroup" => [],
  758. "salePrice" => [
  759. "conversion" => 0,
  760. "unitName" => "件",
  761. "unitId" => 1,
  762. "isMaster" => 5,
  763. "deleteStatus" => 4,
  764. "enabledLadder" => 0,
  765. "salePriceAreaType" => 1,
  766. "salePrice" => $value['price'],
  767. "ladderPrice" => [],
  768. "marketPrice" => $value['price'] * 1.2,
  769. "setNum" => 1
  770. ]
  771. ];
  772. $specMultipleYes = [];
  773. foreach ($value['spec'] as $specValue) {
  774. if ($specValue != '999') {
  775. $specType = 2;//有规格
  776. $specPostData = [
  777. 'hidden' => 4,
  778. 'pid' => 4,
  779. 'specName' => $specValue,
  780. ];
  781. $result = request($specApiUrl, json_encode($specPostData), 10, false, $curl_option);
  782. if ($result['httpcode'] != 200) {
  783. exit($result['content']);
  784. }
  785. $content = json_decode($result['content'], true);
  786. $specGroup['groupSpec'] = [
  787. 'specName' => '默认',
  788. 'specId' => 4,
  789. ];
  790. $specGroup['params'][] = [
  791. 'specValueId' => $content['data']['id'],
  792. 'specValueName' => $content['data']['specName'],
  793. ];
  794. $specMultipleYes[] = [
  795. 'unitId' => 1,
  796. 'unitName' => '件',
  797. 'isMaster' => 5,
  798. 'conversion' => 0,
  799. 'specImage' => '',
  800. 'isDefault' => 4,
  801. 'barCode' => '',
  802. 'specGroup' => [
  803. [
  804. 'specId' => '4',
  805. 'specName' => '默认',
  806. 'specValueName' => $specValue,
  807. 'specValueId' => '5',
  808. ]
  809. ],
  810. 'salePrice' =>
  811. [
  812. 'conversion' => 0,
  813. 'unitName' => '件_' . $specValue,
  814. 'unitId' => 1,
  815. 'isMaster' => 5,
  816. 'deleteStatus' => 4,
  817. 'enabledLadder' => 0,
  818. 'salePriceAreaType' => 1,
  819. 'salePrice' => $value['price'],
  820. 'ladderPrice' => [],
  821. 'marketPrice' => $value['price'] * 1.2,
  822. 'setNum' => 1,
  823. ],
  824. ];
  825. }
  826. }
  827. $specMultiple = $specMultipleNo;
  828. if ($specType == 2) {
  829. $specMultiple = $specMultipleYes;
  830. }
  831. if (!strripos($value['category'], " ")) {
  832. continue;
  833. }
  834. $categoryTitle = substr($value['category'], strripos($value['category'], " ") + 1);
  835. //分类不存在 跳出本次
  836. if (!isset($categoryData[$categoryTitle])) {
  837. continue;
  838. }
  839. $postData = array(
  840. 'categoryPath' => $categoryData[$categoryTitle]['path'],
  841. 'title' => $value['name'],
  842. 'storage' => '',
  843. 'delUnitIds' => [],
  844. 'delSpecSkuIds' => [],
  845. 'specType' => $specType,
  846. 'specGroup' => empty($specGroup) ? $specGroup : [$specGroup],
  847. 'specMultiple' => $specMultiple,
  848. 'unitData' =>
  849. array(
  850. 0 =>
  851. array(
  852. 'barCode' => '',
  853. 'isMaster' => 5,
  854. 'isDefault' => 5,
  855. 'unitName' => '件',
  856. 'unitId' => 1,
  857. ),
  858. ),
  859. 'describe' => '',
  860. 'code' => '',
  861. 'barCode' => '',
  862. 'categoryId' => $categoryData[$categoryTitle]['id'],
  863. 'expireTime' => '',
  864. 'brandId' => '',
  865. 'tag' => '',
  866. 'description' => '',
  867. 'noSalesShop' => '',
  868. 'images' => ["https://onlineimg.qianniao.vip/159929437078955/4c8574ddcbf69ea23bcf403c0b0830e9/logo.jpg"],
  869. 'enableStatus' => 5,
  870. );
  871. $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
  872. if ($result['httpcode'] != 200) {
  873. exit($result['content']);
  874. }
  875. $content = json_decode($result['content'], true);
  876. if ($content['state'] == false) {
  877. exit($content['data']);
  878. }
  879. $i++;
  880. }
  881. echo '执行成功, 共添加' . $i . '条商品';
  882. }
  883. /**
  884. * 我的锅系统商品添加
  885. */
  886. public function addGuoGoods()
  887. {
  888. $apiUrl = 'https://store.qianniaovip.com//app/index.php?i=2&c=entry&do=SaveGoods&m=yb_cy';
  889. $curl_option = [
  890. CURLOPT_HTTPHEADER => [
  891. 'Content-Type:application/json;charset=UTF-8',
  892. ],
  893. ];
  894. $postData = [
  895. "id" => "",
  896. "sort" => "1",
  897. "categoryIds" => [
  898. "13"
  899. ],
  900. "salesNum" => "",
  901. "minNum" => 0,
  902. "maxNum" => 0,
  903. "icon" => "../addons/yb_cy/template/public/img/set/nopic.jpg",
  904. "media" => [
  905. "https => //wodeguo-1303051460.cos.ap-chengdu.myqcloud.com/yb_cy/2020/09/14/0353760156390008.png"
  906. ],
  907. "item" => 1,
  908. "spec" => [
  909. ],
  910. "attribute" => [
  911. ],
  912. "name" => "千鸟云商测试商品",
  913. "group" => [
  914. ],
  915. "boxMoney" => "",
  916. "body" => "",
  917. "outSalesPrice" => 1,
  918. "outPrice" => 0,
  919. "outStock" => 1,
  920. "inSalesPrice" => 1,
  921. "inPrice" => 0,
  922. "inStock" => 1,
  923. "isSpec" => "2",
  924. "isAttribute" => "2",
  925. "required" => "2",
  926. "isMaterial" => "2",
  927. "MaterialIds" => [
  928. ],
  929. "unit" => "13",
  930. "isMember" => "2",
  931. "details" => ""
  932. ];
  933. $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
  934. if ($result['httpcode'] != 200) {
  935. exit($result['content']);
  936. }
  937. $content = json_decode($result['content'], true);
  938. V($content);
  939. }
  940. // public function recived()
  941. // {
  942. //
  943. // $i = 1;
  944. // do {
  945. // $postData = [
  946. // 'topicName' => 'MyJob',
  947. // 'topicClass' => 'Jobs\Model\MTopic\Finance\MReceivable',
  948. // 'topicMethon' => 'checkExistCreate',
  949. // 'topicMethonParams' => [
  950. // 'enterpriseId' => 34,
  951. // ],
  952. // ];
  953. //
  954. // $url = 'http://queue.qianniao.vip:8080/CAddJob/add';
  955. // $result = request($url, $postData);
  956. // print_r($result);
  957. // $i++;
  958. // } while ($result['httpcode'] != 200 && $i <= 3);
  959. // }
  960. public function log()
  961. {
  962. Logger::logs(E_USER_ERROR, '没有错误信息', __CLASS__, __LINE__, '没有错误信息');
  963. }
  964. public function formatUpdateEsData()
  965. {
  966. $curl_option = [
  967. CURLOPT_HTTPHEADER => [
  968. 'Content-Type: application/json'
  969. ],
  970. ];
  971. $postData = [
  972. 'doc' => [
  973. 'status' => 2
  974. ]
  975. ];
  976. for ($i = 1; $i <= 170; $i++) {
  977. if ($i != 19) {
  978. $enableApiUrl = 'http://49.235.209.106:9200/online_customer_search/customer/EnterpriseId_13_CustomerId_' . $i . '/_update';
  979. $result = request($enableApiUrl, json_encode($postData), 1000, false, $curl_option);
  980. var_dump($result['content']);
  981. var_dump('<br/>');
  982. }
  983. }
  984. }
  985. public function autoEnterprise()
  986. {
  987. $objMEnterprise = new MEnterprise();
  988. $return = $objMEnterprise->autoCreateData(1112, 71);
  989. echo $return->getData();
  990. }
  991. public function goodsCateGory()
  992. {
  993. $sql = 'select * from qianniao_goods_category_48 where deleteStatus = 5 and pid = 0';
  994. $category = $this->objDGoods->query($sql);
  995. if ($category === false) {
  996. return ResultWrapper::fail($this->objDGoods->error(), ErrorCode::$paramError);
  997. }
  998. $map = [];
  999. foreach ($category as $item) {
  1000. //' and find_in_set('.$condition['categoryId'].',b.categoryPath) ';
  1001. $sql_1 = 'select g.id from qianniao_goods_48 as g left join qianniao_goods_basic_48 as b
  1002. on g.basicGoodsId = b.id where find_in_set(' . $item['id'] . ',b.categoryPath) and
  1003. g.deleteStatus = 5 And g.enableStatus = 5';
  1004. $sql_2 = 'select g.id from qianniao_goods_48 as g left join qianniao_goods_basic_48 as b
  1005. on g.basicGoodsId = b.id where find_in_set(' . $item['id'] . ',b.categoryPath) and
  1006. g.deleteStatus = 5 And g.enableStatus = 4';
  1007. $u_count = count($this->objDGoods->query($sql_1));
  1008. $b_count = count($this->objDGoods->query($sql_2));
  1009. $map[] = [
  1010. 'id' => $item['id'],
  1011. 'categoryName' => $item['title'],
  1012. 'u_num' => $u_count,
  1013. 'b_num' => $b_count
  1014. ];
  1015. }
  1016. self::export($map);
  1017. die;
  1018. }
  1019. /**
  1020. * 导出方法
  1021. *
  1022. * @param $allOrderData
  1023. */
  1024. private static function export($allOrderData)
  1025. {
  1026. //导出到本地
  1027. header("Content-type:application/vnd.ms-excel");
  1028. header("Content-Disposition:filename=订单记录.csv");
  1029. header('Cache-Control: max-age=0');
  1030. $fp = fopen('php://output', 'a');
  1031. $head = ['ID', '分类名称', '上架数量', '下架数量']; //定义标题
  1032. foreach ($head as $i => $v) {
  1033. $head[$i] = mb_convert_encoding($v, 'GBK', 'utf-8'); //将中文标题转换编码,否则乱码
  1034. }
  1035. fputcsv($fp, $head);
  1036. $limit = 10000;
  1037. $num = 0;//计数器
  1038. foreach ($allOrderData as $v) {
  1039. //循环数据
  1040. $num++;
  1041. if ($num == $limit) {
  1042. ob_flush();//释放内存
  1043. flush();
  1044. }
  1045. $rows['id'] = $v['id'];
  1046. $rows['categoryName'] = $v['categoryName'];
  1047. $rows['u_num'] = $v['u_num'];
  1048. $rows['b_num'] = $v['b_num'];
  1049. foreach ($rows as $kk => $vv) {
  1050. $rs[$kk] = mb_convert_encoding($vv, 'GBK', 'utf-8'); //转译编码
  1051. }
  1052. fputcsv($fp, $rs);
  1053. $rows = [];
  1054. }
  1055. exit;
  1056. }
  1057. /**
  1058. * 处理文件
  1059. * @throws Exception
  1060. * @throws \Exception
  1061. */
  1062. public function formatFIle()
  1063. {
  1064. $file = file('./1.txt');
  1065. $userCenterId = 969;
  1066. $enterpriseId = 56;
  1067. $objMGoodsBasic = new MGoodsBasic($userCenterId, $enterpriseId);
  1068. $objMQuickGoods = new MQuickGoods($enterpriseId, $userCenterId);
  1069. $objMGoods = new MGoods($enterpriseId, false, $userCenterId);
  1070. $array = [];
  1071. foreach ($file as $key => $value) {
  1072. $goodsArray = explode(',', $value);
  1073. if (empty(trim($goodsArray[0])) || in_array(trim($goodsArray[0]), $array)) continue;
  1074. $title = trim($goodsArray[0]) . trim($goodsArray[3]);//商品名字
  1075. $unitId = trim($goodsArray[1]);
  1076. $unitName = trim($goodsArray[2]);
  1077. $describe = '';//卖点
  1078. $categoryId = 2;
  1079. $categoryPath = '2';
  1080. $shopId = 56;
  1081. $shopName = '品茗苑茶行';
  1082. $brandId = 1;
  1083. $addData = [
  1084. //必填字段
  1085. 'title' => $title,//商品名称
  1086. 'brandId' => $brandId,//品牌id
  1087. 'categoryId' => $categoryId,//分类
  1088. 'categoryPath' => $categoryPath,//分类路径
  1089. 'unitData' => [['unitName' => $unitName, 'isMaster' => 5, 'conversion' => '0.00', 'unitId' => $unitId, 'barCode' => '']],//单位
  1090. 'barCode' => '',//条码
  1091. 'describe' => $describe,//卖点
  1092. 'specType' => 1,//单规格1 多规格2
  1093. 'description' => '',
  1094. 'images' => '[]',//商品图册json
  1095. 'expireTime' => 0,
  1096. 'tag' => '',//关键词
  1097. 'link' => '',
  1098. // 'specMultiple' => [],
  1099. // 'shopId' => 46,//商铺id
  1100. // 'shopName' => '纺物优选',//商铺名称
  1101. //
  1102. // 'barCode' => '',
  1103. // 'noSalesShop' => '',
  1104. // 'specGroup' => [],
  1105. // 'extends' => json_encode(['storage'=>'']),
  1106. // 'enableStatus' => 4,
  1107. // 'createUserName' => '',
  1108. // 'sort' => '',
  1109. ];
  1110. //添加商品基础资料
  1111. $modelResult = $objMGoodsBasic->addGoodsBasic($addData);
  1112. if (!$modelResult->isSuccess()) {
  1113. echo $modelResult->getData();
  1114. }
  1115. $basicId = $modelResult->getData();
  1116. $goodsData = [
  1117. 'basicGoodsId' => $basicId,//基本资料id
  1118. 'goodsName' => $title,//基本资料商品名称
  1119. 'shopId' => $shopId,//商铺id
  1120. 'shopName' => $shopName,//商铺名称
  1121. 'images' => '[]',
  1122. 'specType' => 1,//规格类型
  1123. 'enableStatus' => StatusCode::$delete,
  1124. 'priceData' => '',//接json值
  1125. 'createUserName' => '',//添加商品人名称
  1126. ];
  1127. $goodsData['content'] = '';
  1128. $goodsData['isRecommend'] = 4;
  1129. $goodsData['createTime'] = time();
  1130. $goodsData['updateTime'] = time();
  1131. $goodsData['deleteStatus'] = StatusCode::$standard;
  1132. $goodsData['sort'] = 0;
  1133. //添加商品
  1134. $modelResult = $objMGoods->addGoods($goodsData);
  1135. if (!$modelResult->isSuccess()) {
  1136. echo $modelResult->getData();
  1137. }
  1138. $array[] = $title;
  1139. //单店铺添加商品
  1140. // $modelResult = $objMQuickGoods->addBasicAndPublishGoods($addData);
  1141. // if (!$modelResult->isSuccess()) {
  1142. // echo $modelResult->getData();
  1143. // }
  1144. // if($key > 1){
  1145. // break;
  1146. // }
  1147. }
  1148. echo '成功';
  1149. }
  1150. /**
  1151. * 格式化分类
  1152. * @throws Exception
  1153. */
  1154. public function formatFIleCategory()
  1155. {
  1156. $file = file('./2.txt');
  1157. $objDSku = new DSku();
  1158. foreach ($file as $value) {
  1159. $explodeData = explode(':', $value);
  1160. $goodsBasicData = trim($explodeData[0]);
  1161. $goodsCategoryData = trim($explodeData[1]);
  1162. //判断是一级分类还是多级分类
  1163. if (strstr($goodsCategoryData, ',')) {
  1164. //多级分类
  1165. $categoryData = explode(',', $goodsCategoryData);
  1166. $categoryPath = '';
  1167. $categoryId = 0;
  1168. foreach ($categoryData as $key => $v) {
  1169. $category = trim($v);
  1170. //查询分类表是否有这个分类的名称
  1171. $sql = 'select * from qianniao_goods_category_34 where title = ' . trim($category) . ' and pid = ' . $categoryId;
  1172. $dbResult = $objDSku->query($sql);
  1173. if ($dbResult === false) {
  1174. echo $objDSku->error();
  1175. break;
  1176. }
  1177. //如果不存在 插入一条分类
  1178. if (empty($dbResult)) {
  1179. $sql = 'insert into qianniao_goods_category_34 (pid, title, createTime, updateTime) values(' . $categoryId . ', "' . trim($category) . '", ' . time() . ', ' . time() . ')';
  1180. $insertResult = $objDSku->query($sql);
  1181. if ($insertResult === false) {
  1182. echo $objDSku->error();
  1183. break;
  1184. }
  1185. $id = $insertResult;
  1186. } else {
  1187. $id = $dbResult[0]['id'];
  1188. }
  1189. $categoryId = $id;
  1190. $categoryPath = $categoryId == 0 ? $id : $categoryPath . ',' . $id;
  1191. }
  1192. } else {
  1193. //一级分类
  1194. //查询分类表是否有这个分类的名称
  1195. $sql = 'select * from qianniao_goods_category_34 where title = ' . trim($goodsCategoryData) . ' and pid = 0';
  1196. $dbResult = $objDSku->query($sql);
  1197. if ($dbResult === false) {
  1198. echo $objDSku->error();
  1199. break;
  1200. }
  1201. //如果不存在 插入一条分类
  1202. if (empty($dbResult)) {
  1203. $sql = 'insert into qianniao_goods_category_34 (pid, title, createTime, updateTime) values(0, "' . trim($goodsCategoryData) . '", ' . time() . ', ' . time() . ')';
  1204. $categoryId = $objDSku->query($sql);
  1205. if ($categoryId === false) {
  1206. echo $objDSku->error();
  1207. break;
  1208. }
  1209. } else {
  1210. $categoryId = $dbResult[0]['id'];
  1211. }
  1212. $categoryPath = $categoryId;
  1213. }
  1214. //根据该商品名称修改分类字段
  1215. $sql = 'update qianniao_goods_basic_34 set categoryId = ' . $categoryId . ', categoryPath = ' . $categoryPath . ' where title = "' . $goodsBasicData . '"';
  1216. $dbResult = $objDSku->query($sql);
  1217. if ($dbResult === false) {
  1218. echo $objDSku->error();
  1219. break;
  1220. }
  1221. }
  1222. }
  1223. /**
  1224. * 测试 获取缓存
  1225. * @throws Exception
  1226. */
  1227. public function getCache()
  1228. {
  1229. $objMOrder = new MOrder(1, 1);
  1230. $result = $objMOrder->businessOverview('todayConfirmedOrderNum', '');
  1231. V($result);
  1232. }
  1233. public function test_request()
  1234. {
  1235. $apiUrl = 'http://api.qianniao.vip/Goods/Goods/addGoods';
  1236. $enableApiUrl = 'http://api.qianniao.vip/Goods/Goods/updateEnableStatus';
  1237. $curl_option = [
  1238. CURLOPT_HTTPHEADER => [
  1239. 'Content-Type:text/plain',
  1240. 'Authorization:eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjU2OSwiZXhwaXJlVGltZSI6MTU5MTUwMDQ1M30.y5HnUgq7dZ4lgk4bCK_l7FJr_UpelHYtvgLX4Hpa5fs',
  1241. 'Token:8fa553d53f44e33123e4d0d51a0de634'
  1242. ],
  1243. ];
  1244. $objDGoodsBasic = new DGoodsBasic();
  1245. $objSku = new DSku();
  1246. $sql = 'select b.* from qianniao_goods_basic_34 as b left join qianniao_goods_34 as g on b.id = g.basicGoodsId WHERE g.basicGoodsId IS NULL';
  1247. $dbResult = $objDGoodsBasic->query($sql);
  1248. foreach ($dbResult as $row) {
  1249. $skuData = $objSku->query('select * from qianniao_sku_34 where goodsId = ' . $row['id'] . ' and deleteStatus = 5');
  1250. $postData = [
  1251. "createUserName" => "陈民",
  1252. "goodsName" => $row['title'],
  1253. "specType" => $row['specType'],
  1254. "goodsBasicId" => $row['id'],
  1255. "shopId" => 38,
  1256. "shopName" => "万货网",
  1257. "images" => json_decode($row['images'], true),
  1258. "salesArea" => [],
  1259. "serviceInfo" => 1,
  1260. "price" => [
  1261. [
  1262. "id" => $skuData[0]['id'],
  1263. "unitId" => $skuData[0]['unitId'],
  1264. "unitName" => $skuData[0]['unitName'],
  1265. "conversion" => "0.00",
  1266. "isMaster" => 5,
  1267. "enabledLadder" => 0,
  1268. "marketPrice" => 1000,
  1269. "salePrice" => 999,
  1270. "setNum" => 1,
  1271. "salePriceAreaType" => 1,
  1272. "ladderPrice" => []
  1273. ]
  1274. ],
  1275. "specification" => [
  1276. null
  1277. ],
  1278. "content" => "",
  1279. "isRecommend" => 5,
  1280. "sort" => "1"
  1281. ];
  1282. $result = request($apiUrl, json_encode($postData), 10, false, $curl_option);
  1283. if ($result['httpcode'] != 200) {
  1284. return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
  1285. }
  1286. $reponse = json_decode($result['content'], true);
  1287. if (isset($reponse) && $reponse['errorcode'] == 0) {
  1288. $enableData = [
  1289. 'enableStatus' => StatusCode::$standard,
  1290. 'id' => (int)$reponse['data']
  1291. ];
  1292. $enableResponse = request($enableApiUrl, json_encode($enableData), 10, false, $curl_option);
  1293. }
  1294. //V(123);
  1295. }
  1296. return ResultWrapper::success($reponse['data']);
  1297. }
  1298. /**
  1299. * @throws Exception
  1300. */
  1301. public function syncGoodsAndGoodsBasic()
  1302. {
  1303. $objDGoodsBasic = new DGoodsBasic();
  1304. $objDGoods = new DGoods();
  1305. $objDGoods->setTable('qianniao_goods_34');
  1306. $objDGoodsBasic->setTable('qianniao_goods_basic_34');
  1307. $goodsBasicData = $objDGoodsBasic->select([], 'id,images');
  1308. if ($goodsBasicData === false) {
  1309. exit("sql:" . $objDGoodsBasic->error());
  1310. }
  1311. foreach ($goodsBasicData as $row) {
  1312. $update = $objDGoods->update(['images' => $row['images']], ['basicGoodsId' => $row['id']]);
  1313. if ($update === false) {
  1314. exit("sql:" . $objDGoods->error());
  1315. }
  1316. }
  1317. V("操作成功");
  1318. }
  1319. /**
  1320. * Test constructor.
  1321. */
  1322. public function __construct()
  1323. {
  1324. $this->objDGoods = new DGoods();
  1325. // $this->Authorization = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOjgyNywiZXhwaXJlVGltZSI6MTU5NTgzMDUzN30.Rua2aBXgwh_hIAkp6M1KHYYtCzcsTgEdLqvD-c8-pmw';
  1326. // $this->Token = 'a946c2ed5c589bfe0f66e48facb32649';
  1327. }
  1328. /**public function addOrder()
  1329. * {
  1330. * echo "start".PHP_EOL;
  1331. * $apiUrl = 'http://api.qianniao.vip/Order/Order/addOrder/613';
  1332. * $curl_option = [
  1333. * CURLOPT_HTTPHEADER => [
  1334. * 'Content-Type:text/plain',
  1335. * 'Authorization:'.$this->Authorization,
  1336. * 'Token:'.$this->Token
  1337. * ],
  1338. * ];
  1339. * //$postData = '{"deliveryType":1,"customerName":"清扬超市","receiveAddressId":141,"source":"3","orderRemark":"新日期","goodsData":{"totalMoney":"406.05","payMoney":"406.05","preferential":"0.00","vipDiscount":0,"vipDoubleDiscount":0,"activityMoney":"0.00","checkNum":5,"cartNum":5,"goodsNum":29,"goodsData":[{"shopId":38,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","totalMoney":"406.05","preferential":"0.00","payMoney":"406.05","shopGoodsData":[{"id":2536,"goodsId":483,"goodsCode":"MATERIEL000483","buyNum":5,"shopId":38,"goodsBasicId":483,"selection":5,"skuId":483,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2536,"brandName":"","categoryName":"膨化食品","barCode":"6924743919242","storageCode":"H1-2-1-3","goodsName":"乐事墨西哥鸡汁番茄味薯片70g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591509958101乐事墨西哥鸡汁番茄味薯片70g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":99,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"4.65","price":"4.65","preferential":0,"totalMoney":"23.25","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"4.3200","inventoryNum":"17.00000000","conversion":0},{"id":2535,"goodsId":517,"goodsCode":"MATERIEL000517","buyNum":4,"shopId":38,"goodsBasicId":517,"selection":5,"skuId":517,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2535,"brandName":"健力宝","categoryName":"膨化食品","barCode":"6920912341852","storageCode":"A2-1-4-1","goodsName":"盼盼家庭号经济包薯片原味108g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591509094748盼盼家庭号经济包薯片原味108g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":1,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.45","price":"2.45","preferential":0,"totalMoney":"9.80","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.1000","inventoryNum":"54.00000000","conversion":0},{"id":2534,"goodsId":495,"goodsCode":"MATERIEL000495","buyNum":10,"shopId":38,"goodsBasicId":495,"selection":5,"skuId":495,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2534,"brandName":"","categoryName":"膨化食品","barCode":"6909409012802","storageCode":"A1-1-3-4","goodsName":"上好佳草莓味栗米条40g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591509681566上好佳草莓味栗米条40g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":102,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.70","price":"2.70","preferential":0,"totalMoney":"27.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.6000","inventoryNum":"30.00000000","conversion":0},{"id":2533,"goodsId":64,"goodsCode":"MATERIEL000064","buyNum":8,"shopId":38,"goodsBasicId":64,"selection":5,"skuId":64,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2533,"brandName":"","categoryName":"果汁饮料","barCode":"","storageCode":"","goodsName":"康师傅冰红茶1L*12瓶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591581053066康师傅茉莉蜜茶1l.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":18,"brandId":109,"categoryPath":"18","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"34.50","price":"34.50","preferential":0,"totalMoney":"276.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"34.6660","inventoryNum":"10.00000000","conversion":0},{"id":2532,"goodsId":63,"goodsCode":"MATERIEL000063","buyNum":2,"shopId":38,"goodsBasicId":63,"selection":5,"skuId":63,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2532,"brandName":"","categoryName":"果汁饮料","barCode":"6921317989847","storageCode":"C1-1-15","goodsName":"康师傅蜂蜜绿茶1L*12瓶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591581068709康师傅绿茶1l.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":18,"brandId":109,"categoryPath":"18","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"35.00","price":"35.00","preferential":0,"totalMoney":"70.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"34.6500","inventoryNum":"5.00000000","conversion":0}]}],"invalidData":[]}}';
  1340. * $postData = '{"deliveryType":1,"customerName":"诚信百货超市","receiveAddressId":7,"source":"3","orderRemark":"","goodsData":{"totalMoney":"420.75","payMoney":"420.75","preferential":"0.00","vipDiscount":0,"vipDoubleDiscount":0,"activityMoney":"0.00","checkNum":15,"cartNum":15,"goodsNum":60,"goodsData":[{"shopId":38,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","totalMoney":"420.75","preferential":"0.00","payMoney":"420.75","shopGoodsData":[{"id":2552,"goodsId":575,"goodsCode":"MATERIEL000575","buyNum":10,"shopId":38,"goodsBasicId":575,"selection":5,"skuId":575,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2552,"brandName":"","categoryName":"坚果炒货","barCode":"6922742001180","storageCode":"A2-3-3-3","goodsName":"沙土原香瓜子200g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591504718336沙土原香瓜子200g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":118,"brandId":104,"categoryPath":"118","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"3.70","price":"3.70","preferential":0,"totalMoney":"37.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"4.2538","inventoryNum":"61.00000000","conversion":0},{"id":2550,"goodsId":574,"goodsCode":"MATERIEL000574","buyNum":20,"shopId":38,"goodsBasicId":574,"selection":5,"skuId":574,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2550,"brandName":"","categoryName":"坚果炒货","barCode":"6922742000848","storageCode":"A2-3-3-2","goodsName":"沙土香瓜子300g","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591504774300沙土香瓜子300g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":118,"brandId":104,"categoryPath":"118","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"5.95","price":"5.95","preferential":0,"totalMoney":"119.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"5.6200","inventoryNum":"140.00000000","conversion":0},{"id":2549,"goodsId":345,"goodsCode":"MATERIEL000345","buyNum":2,"shopId":38,"goodsBasicId":345,"selection":5,"skuId":345,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2549,"brandName":"","categoryName":"熟食卤味","barCode":"6935284413991","storageCode":"F1-4-3-5","goodsName":"卫龙亲嘴烧选B麦辣鸡汁味28g*20包","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591513223408卫龙亲嘴烧选B麦辣鸡汁味28g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":13,"brandId":89,"categoryPath":"13","isActivity":4,"specType":1,"unitName":"盒","specGroup":[],"originPrice":"14.50","price":"14.50","preferential":0,"totalMoney":"29.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"13.0000","inventoryNum":"2.00000000","conversion":0},{"id":2548,"goodsId":72,"goodsCode":"MATERIEL000072","buyNum":1,"shopId":38,"goodsBasicId":72,"selection":5,"skuId":72,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2548,"brandName":"","categoryName":"茶饮料","barCode":"4891599366839","storageCode":"C1-1-8","goodsName":"加多宝凉茶植物饮料550ML*15瓶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591580637360主图-1 (1).jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":15,"brandId":72,"categoryPath":"15","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"43.80","price":"43.80","preferential":0,"totalMoney":"43.80","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"42.0000","inventoryNum":"5.00000000","conversion":0},{"id":2547,"goodsId":440,"goodsCode":"MATERIEL000440","buyNum":3,"shopId":38,"goodsBasicId":440,"selection":5,"skuId":440,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2547,"brandName":"","categoryName":"膨化食品","barCode":"6922330265543","storageCode":"F1-9-1-1","goodsName":"运康牛肉口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510887159运康牛肉口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9367","inventoryNum":"51.00000000","conversion":0},{"id":2546,"goodsId":441,"goodsCode":"MATERIEL000441","buyNum":3,"shopId":38,"goodsBasicId":441,"selection":5,"skuId":441,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2546,"brandName":"","categoryName":"膨化食品","barCode":"6922330265529","storageCode":"F1-9-2-1","goodsName":"运康香辣口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510878227运康香辣口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.0000","inventoryNum":"44.00000000","conversion":0},{"id":2545,"goodsId":442,"goodsCode":"MATERIEL000442","buyNum":3,"shopId":38,"goodsBasicId":442,"selection":5,"skuId":442,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2545,"brandName":"","categoryName":"膨化食品","barCode":"6922330255001","storageCode":"F1-9-1-2","goodsName":"运康五香口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510880914运康五香口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"2.0000","inventoryNum":"5.00000000","conversion":0},{"id":2544,"goodsId":443,"goodsCode":"MATERIEL000443","buyNum":3,"shopId":38,"goodsBasicId":443,"selection":5,"skuId":443,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2544,"brandName":"","categoryName":"膨化食品","barCode":"6922330265703","storageCode":"F1-9-2-3","goodsName":"运康鸡肉口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510893356运康鸡肉口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9000","inventoryNum":"50.00000000","conversion":0},{"id":2543,"goodsId":444,"goodsCode":"MATERIEL000444","buyNum":3,"shopId":38,"goodsBasicId":444,"selection":5,"skuId":444,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2543,"brandName":"","categoryName":"膨化食品","barCode":"6922330265512","storageCode":"F1-9-2-2","goodsName":"运康烧烤口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510884090运康烧烤口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9166","inventoryNum":"60.00000000","conversion":0},{"id":2542,"goodsId":445,"goodsCode":"MATERIEL000445","buyNum":3,"shopId":38,"goodsBasicId":445,"selection":5,"skuId":445,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2542,"brandName":"","categoryName":"膨化食品","barCode":"6922330265581","storageCode":"F1-9-2-4","goodsName":"运康麻辣口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510890646运康麻辣口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.45","price":"2.45","preferential":0,"totalMoney":"7.35","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9397","inventoryNum":"53.00000000","conversion":0},{"id":2541,"goodsId":446,"goodsCode":"MATERIEL000446","buyNum":3,"shopId":38,"goodsBasicId":446,"selection":5,"skuId":446,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2541,"brandName":"","categoryName":"膨化食品","barCode":"","storageCode":"","goodsName":"运康羊肉串口味锅巴102g袋装","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591510875264运康羊肉串口味锅巴102g袋装.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":2,"brandId":97,"categoryPath":"2","isActivity":4,"specType":1,"unitName":"包","specGroup":[],"originPrice":"2.30","price":"2.30","preferential":0,"totalMoney":"6.90","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"1.9000","inventoryNum":"50.00000000","conversion":0},{"id":2540,"goodsId":349,"goodsCode":"MATERIEL000349","buyNum":2,"shopId":38,"goodsBasicId":349,"selection":5,"skuId":349,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2540,"brandName":"","categoryName":"熟食卤味","barCode":"6935284415162","storageCode":"F1-4-2-1","goodsName":"卫龙魔芋爽酸辣素毛肚18g*20包","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591513176969卫龙魔芋爽酸辣素毛肚18g_20.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":13,"brandId":89,"categoryPath":"13","isActivity":4,"specType":1,"unitName":"盒","specGroup":[],"originPrice":"14.50","price":"14.50","preferential":0,"totalMoney":"29.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"12.7343","inventoryNum":"10.00000000","conversion":0},{"id":2539,"goodsId":347,"goodsCode":"MATERIEL000347","buyNum":2,"shopId":38,"goodsBasicId":347,"selection":5,"skuId":347,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2539,"brandName":"","categoryName":"熟食卤味","barCode":"6935284414011","storageCode":"F1-4-3-4","goodsName":"卫龙亲嘴烧选C川香风味28g*20包","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591513220899卫龙亲嘴烧选C川香风味28g_20.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":13,"brandId":89,"categoryPath":"13","isActivity":4,"specType":1,"unitName":"盒","specGroup":[],"originPrice":"14.50","price":"14.50","preferential":0,"totalMoney":"29.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"13.0000","inventoryNum":"2.00000000","conversion":0},{"id":2538,"goodsId":678,"goodsCode":"MATERIEL000678","buyNum":1,"shopId":38,"goodsBasicId":678,"selection":5,"skuId":678,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2538,"brandName":"","categoryName":"方便面/粉","barCode":"","storageCode":"","goodsName":"康师傅鲜虾鱼板面95g*24袋","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591502015830康师傅鲜虾鱼板面95g.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":22,"brandId":109,"categoryPath":"22","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"47.50","price":"47.50","preferential":0,"totalMoney":"47.50","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"46.0000","inventoryNum":"2.00000000","conversion":0},{"id":2537,"goodsId":663,"goodsCode":"MATERIEL000663","buyNum":1,"shopId":38,"goodsBasicId":663,"selection":5,"skuId":663,"warehouseId":1,"activityId":0,"shopName":"济南万货网自营仓","shopLogo":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591611913629fbcd6ad1f75737ddcbd5a9eaaba9586f.png?imageView2/2/w/750/h/750","cartId":2537,"brandName":"","categoryName":"方便面/粉","barCode":"6903252100785","storageCode":"","goodsName":"康师傅红烧牛肉面109g*12桶","goodsImages":"https://onlineimg.qianniao.vip/8fa553d53f44e33123e4d0d51a0de634/1591502332247康师傅红烧牛肉面108g-12桶.jpg?imageView2/2/w/750/h/750","isInvalid":5,"describe":"","categoryId":22,"brandId":109,"categoryPath":"22","isActivity":4,"specType":1,"unitName":"件","specGroup":[],"originPrice":"38.00","price":"38.00","preferential":0,"totalMoney":"38.00","activityMoney":0,"isMutex":4,"vipDiscount":0,"inventory":0,"costPrice":"37.0000","inventoryNum":"7.00000000","conversion":0}]}],"invalidData":[]}}';
  1341. * $result = request($apiUrl, $postData, 60, false, $curl_option);
  1342. * if ($result['httpcode'] != 200) {
  1343. * return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
  1344. * }
  1345. * $reponse = json_decode($result['content'], true);
  1346. * V($reponse);
  1347. * }**/
  1348. public function bugCategoryPath()
  1349. {
  1350. $fields = 'b.id,b.title,b.categoryPath,b.categoryId';
  1351. $sql = 'SELECT ' . $fields . ' FROM qianniao_goods_basic_48 as b
  1352. LEFT JOIN qianniao_goods_category_48 as c ON
  1353. c.id = b.categoryId WHERE c.pid != 0';
  1354. $result = $this->objDGoods->query($sql);
  1355. if ($result === false) {
  1356. echo 'sql' . $this->objDGoods->error();
  1357. die;
  1358. }
  1359. $allCategoryIds = [];
  1360. foreach ($result as $item) {
  1361. $allCategoryIds[] = $item['categoryId'];
  1362. }
  1363. //获取这些分类的全路径
  1364. $c_sql = 'SELECT id,pid,title FROM qianniao_goods_category_48 WHERE deleteStatus=5';
  1365. $category = $this->objDGoods->query($c_sql);
  1366. $allCategory = [];
  1367. foreach ($category as $item) {
  1368. $allCategory[$item['id']] = $item;
  1369. }
  1370. foreach ($allCategory as &$item) {
  1371. if ($item['pid'] == 0) {
  1372. $item['categoryPath'] = $item['id'];
  1373. } else {
  1374. $item['categoryPath'] = $item['pid'] . ',' . $item['id'];
  1375. }
  1376. }
  1377. unset($item);
  1378. foreach ($result as $key => $item) {
  1379. $result[$key]['categoryPath'] = $allCategory[$item['categoryId']]['categoryPath'];
  1380. }
  1381. $objDGoodsBasic = new DGoodsBasic();
  1382. $objDGoodsBasic->setTable('qianniao_goods_basic_48');
  1383. foreach ($result as $value) {
  1384. $update = $objDGoodsBasic->update([
  1385. 'categoryPath' => $value['categoryPath']
  1386. ], ['id' => $value['id']]);
  1387. if ($update === true) {
  1388. echo 'sql' . $objDGoodsBasic->error();
  1389. }
  1390. }
  1391. echo 'success';
  1392. }
  1393. /**
  1394. * 基础商品
  1395. * @return ResultWrapper
  1396. */
  1397. public function goodsBasic()
  1398. {
  1399. echo "start" . PHP_EOL;
  1400. $apiUrl = 'http://api.qianniao.vip/GoodsManage/GoodsBasic/fixEsData';
  1401. $curl_option = [
  1402. CURLOPT_HTTPHEADER => [
  1403. 'Content-Type:text/plain',
  1404. 'Authorization:' . $this->Authorization,
  1405. 'Token:' . $this->Token
  1406. ],
  1407. ];
  1408. $postData = [
  1409. "page" => 0,
  1410. "pageSize" => 2000,
  1411. ];
  1412. $result = request($apiUrl, json_encode($postData), 60, false, $curl_option);
  1413. if ($result['httpcode'] != 200) {
  1414. return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
  1415. }
  1416. $reponse = json_decode($result['content'], true);
  1417. V($reponse);
  1418. }
  1419. /**
  1420. * 修补商品es数据
  1421. */
  1422. public function goods_fixEsData()
  1423. {
  1424. echo 'start' . PHP_EOL;
  1425. $apiUrl = 'http://api.qianniao.vip/Goods/Goods/fixEsData';
  1426. $curl_option = [
  1427. CURLOPT_HTTPHEADER => [
  1428. 'Content-Type:text/plain',
  1429. 'Authorization:' . $this->Authorization,
  1430. 'Token:' . $this->Token
  1431. ],
  1432. ];
  1433. $postData = [
  1434. "page" => 0,
  1435. "pageSize" => 2000
  1436. ];
  1437. $result = request($apiUrl, json_encode($postData), 60, false, $curl_option);
  1438. if ($result['httpcode'] != 200) {
  1439. return ResultWrapper::fail($result['content'], ErrorCode::$apiNotResult);
  1440. }
  1441. $reponse = json_decode($result['content'], true);
  1442. V($reponse);
  1443. }
  1444. /**
  1445. * 基础资料
  1446. * @throws Exception
  1447. */
  1448. public function test_replace()
  1449. {
  1450. $objDGoodsBasic = new DGoodsBasic();
  1451. $objDGoodsBasic->setTable('qianniao_goods_basic_1');
  1452. $sql = 'select id,images,description from qianniao_goods_basic_1';
  1453. $dbResult = $objDGoodsBasic->query($sql);
  1454. if ($dbResult === false) {
  1455. exit("获取数据失败" . $objDGoodsBasic->error());
  1456. }
  1457. foreach ($dbResult as $row) {
  1458. if (empty($row['images'])) {
  1459. continue;
  1460. }
  1461. $images = json_decode($row['images'], true);
  1462. foreach ($images as &$item) {
  1463. $item = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $item);
  1464. }
  1465. $images = json_encode($images);
  1466. $description = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['description']);
  1467. $updateResult = $objDGoodsBasic->update(['images' => $images, 'description' => $description], ['id' => $row['id']]);
  1468. if ($updateResult === false) {
  1469. exit('更新失败' . $objDGoodsBasic->error());
  1470. }
  1471. }
  1472. exit('操作成功');
  1473. }
  1474. /**
  1475. *
  1476. * @throws Exception
  1477. */
  1478. public function test_replace_goods()
  1479. {
  1480. $objDGoods = new DGoods();
  1481. $objDGoods->setTable('qianniao_goods_1');
  1482. $sql = 'select id,images,content from qianniao_goods_1';
  1483. $dbResult = $objDGoods->query($sql);
  1484. if ($dbResult === false) {
  1485. exit("获取数据失败" . $objDGoods->error());
  1486. }
  1487. foreach ($dbResult as $row) {
  1488. if (empty($row['images'])) {
  1489. continue;
  1490. }
  1491. $images = json_decode($row['images'], true);
  1492. foreach ($images as &$item) {
  1493. $item = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $item);
  1494. }
  1495. $images = json_encode($images);
  1496. $content = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['content']);
  1497. $updateResult = $objDGoods->update(['images' => $images, 'content' => $content], ['id' => $row['id']]);
  1498. if ($updateResult === false) {
  1499. exit('更新失败' . $objDGoods->error());
  1500. }
  1501. }
  1502. exit('操作成功');
  1503. }
  1504. /**
  1505. *
  1506. * @throws Exception
  1507. */
  1508. public function test_replace_category()
  1509. {
  1510. $objDGoodsCategory = new DGoodsCategory();
  1511. $objDGoodsCategory->setTable('qianniao_goods_category_1');
  1512. $sql = 'select id,images,adImage from qianniao_goods_category_1';
  1513. $dbResult = $objDGoodsCategory->query($sql);
  1514. if ($dbResult === false) {
  1515. exit("获取数据失败" . $objDGoodsCategory->error());
  1516. }
  1517. foreach ($dbResult as $row) {
  1518. if (empty($row['images'])) {
  1519. continue;
  1520. }
  1521. $images = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['images']);
  1522. $adImage = str_replace('https://image.saiyin168.cn', 'https://image.qpl123.com', $row['adImage']);
  1523. $updateResult = $objDGoodsCategory->update(['images' => $images, 'adImage' => $adImage], ['id' => $row['id']]);
  1524. if ($updateResult === false) {
  1525. exit('更新失败' . $objDGoodsCategory->error());
  1526. }
  1527. }
  1528. exit('操作成功');
  1529. }
  1530. public function forApi()
  1531. {
  1532. $objMCustomer = new MCustomer(4, 29);
  1533. $obj = new DCustomer();
  1534. $sql = 'select * from qianniao_customer_4 where deleteStatus = 5';
  1535. $result = $obj->query($sql);
  1536. foreach ($result as $key => $value) {
  1537. $a = $objMCustomer->updateEsData($value['id']);
  1538. }
  1539. }
  1540. /**
  1541. * @throws Exception
  1542. */
  1543. public function syncSku()
  1544. {
  1545. $objSkuCache = new SkuCache(1);
  1546. $objDSku = new DSku();
  1547. $objDSku->setTable('qianniao_sku_1');
  1548. $skuResult = $objDSku->select([]);
  1549. if ($skuResult === false) {
  1550. exit($objDSku->error());
  1551. }
  1552. foreach ($skuResult as $item) {
  1553. $map = self::cacheMappersSku($item);
  1554. $objSkuCache->delSku($item['id']);
  1555. $cacheRes = $objSkuCache->cacheSku($item['id'], $map);
  1556. if (!$cacheRes->isSuccess()) {
  1557. exit("缓存失败");
  1558. }
  1559. }
  1560. exit("缓存成功");
  1561. }
  1562. /**
  1563. * @param array $data
  1564. * @return array
  1565. */
  1566. public static function cacheMappersSku(array $data)
  1567. {
  1568. $map = [];
  1569. if (empty($data)) {
  1570. return $map;
  1571. }
  1572. $map = [
  1573. 'id' => $data['id'],
  1574. 'unitId' => $data['unitId'],
  1575. 'unitName' => $data['unitName'],
  1576. 'isMaster' => $data['isMaster'],
  1577. 'conversion' => $data['conversion'],
  1578. 'specType' => $data['specType'],
  1579. 'specImage' => $data['specImage'],
  1580. 'specData' => $data['specData'],
  1581. 'specGroupHash' => $data['specGroupHash'],
  1582. 'barCode' => $data['barCode'],
  1583. 'goodsId' => $data['goodsId']
  1584. ];
  1585. return $map;
  1586. }
  1587. /**
  1588. * 测试打印
  1589. */
  1590. public function sendMsg()
  1591. {
  1592. $CloudPrint = new CloudPrint();
  1593. $BaseModel = new MBaseModel();
  1594. $data = [
  1595. 'shopName' => '千鸟云商',
  1596. 'title' => '销售单',
  1597. 'code' => '0000000009',
  1598. 'codeName' => '订单编号',
  1599. 'userName' => '海燕',
  1600. 'mobile' => 13626403927,
  1601. 'address' => '西安大明宫万达',
  1602. 'createTime' => time(),
  1603. 'details' => [
  1604. [
  1605. 'title' => '紫苏焖鹅+梅菜肉饼+椒盐虾+北京烤鸭',
  1606. 'skuData' => [
  1607. [
  1608. 'skuName' => '白色;XL',
  1609. 'unitName' => '件',
  1610. 'num' => 11,
  1611. 'unitPrice' => 10.00,
  1612. 'amountPrice' => 110.00
  1613. ],
  1614. [
  1615. 'skuName' => '白色;XL',
  1616. 'unitName' => '件',
  1617. 'num' => 11,
  1618. 'unitPrice' => 10.00,
  1619. 'amountPrice' => 110.00
  1620. ],
  1621. [
  1622. 'skuName' => '白色;XL',
  1623. 'unitName' => '件',
  1624. 'num' => 11,
  1625. 'unitPrice' => 10,
  1626. 'amountPrice' => 110
  1627. ],
  1628. [
  1629. 'skuName' => '白色;XL',
  1630. 'unitName' => '件',
  1631. 'num' => 11,
  1632. 'unitPrice' => 10,
  1633. 'amountPrice' => 110
  1634. ],
  1635. ]
  1636. ],
  1637. [
  1638. 'title' => '紫苏焖鹅+梅菜肉饼+椒盐虾+北京烤鸭',
  1639. 'skuData' => [
  1640. [
  1641. 'skuName' => '橘子味',
  1642. 'unitName' => '瓶',
  1643. 'num' => 1,
  1644. 'unitPrice' => 5,
  1645. 'amountPrice' => 5,
  1646. ]
  1647. ],
  1648. ]
  1649. ],
  1650. 'totalMoney' => 12.00,
  1651. 'preferential' => 0,
  1652. 'payAmount' => 12.00
  1653. ];
  1654. // $data = $BaseModel->formatMsg($data);
  1655. // $result = $CloudPrint->sendMsg($data);
  1656. // $result = $CloudPrint->getStatus();
  1657. // $result = $CloudPrint->setVolume(0);
  1658. //测试飞鹅打印机
  1659. $data = $BaseModel->formatMsg($data, 2);
  1660. $result = $CloudPrint->feieSendMsg($data);
  1661. V($result);
  1662. }
  1663. public function bugCoupon()
  1664. {
  1665. $objDUserCoupon = new DUserCoupon();
  1666. $objDUserCoupon->setTable('qianniao_user_coupon_13');
  1667. $userCenterIds = [];
  1668. $couponIds = [];
  1669. $couponIdsStr = implode(',', $couponIds);
  1670. $sql = 'select * from qianniao_coupon_13 where id in (' . $couponIdsStr . ')';
  1671. $coupon = $this->objDGoods->query($sql);
  1672. if ($coupon === false) {
  1673. echo 'sql' . $this->objDGoods->error();
  1674. }
  1675. $couponMap = [];
  1676. foreach ($coupon as $key => $value) {
  1677. if ($value['receiveNum'] >= $value['totalNum']) {
  1678. unset($coupon[$key]);
  1679. continue;
  1680. }
  1681. $couponMap[$value['id']] = $value;
  1682. }
  1683. $insert = [];
  1684. foreach ($userCenterIds as $item) {
  1685. foreach ($couponMap as $key => $value) {
  1686. $count = $objDUserCoupon->count(['couponId' => $value['id'], 'userId' => $item['uid']]);
  1687. if ($count >= $value['allowNum']) {
  1688. continue;
  1689. }
  1690. //剩余数量不足每人领取数量
  1691. if ($value['receiveNum'] + $value['allowNum'] > $value['totalNum']) {
  1692. $rec = $value['totalNum'] - $value['receiveNum'];
  1693. for ($i = 0; $i < $rec; $i++) {
  1694. $insert[] = [
  1695. 'couponId' => $value['id'],
  1696. 'name' => $value['name'],
  1697. 'remark' => $value['remark'],
  1698. 'couponType' => $value['couponType'],
  1699. 'reducePrice' => $value['reducePrice'],
  1700. 'minPrice' => $value['minPrice'],
  1701. 'startTime' => $value['startTime'],
  1702. 'endTime' => $value['endTime'],
  1703. 'applyRange' => $value['applyRange'],
  1704. 'categoryCollect' => $value['categoryCollect'],
  1705. 'brandCollect' => $value['brandCollect'],
  1706. 'isExpire' => StatusCode::$delete,
  1707. 'isUse' => StatusCode::$standard,
  1708. 'userId' => $item['uid'],
  1709. 'useShop' => $value['useShop'],
  1710. 'customerId' => $item['cId'],
  1711. 'source' => $value['grantType'],
  1712. 'createTime' => time(),
  1713. 'updateTime' => time(),
  1714. 'customerIds' => $value['customerIds'],
  1715. 'isMutex' => isset($value['isMutex']) ? $value['isMutex'] : StatusCode::$standard,
  1716. ];
  1717. }
  1718. continue;
  1719. }
  1720. for ($i = 0; $i < $value['allowNum']; $i++) {
  1721. $insert[] = [
  1722. 'couponId' => $value['id'],
  1723. 'name' => $value['name'],
  1724. 'remark' => $value['remark'],
  1725. 'couponType' => $value['couponType'],
  1726. 'reducePrice' => $value['reducePrice'],
  1727. 'minPrice' => $value['minPrice'],
  1728. 'startTime' => $value['startTime'],
  1729. 'endTime' => $value['endTime'],
  1730. 'applyRange' => $value['applyRange'],
  1731. 'categoryCollect' => $value['categoryCollect'],
  1732. 'brandCollect' => $value['brandCollect'],
  1733. 'isExpire' => StatusCode::$delete,
  1734. 'isUse' => StatusCode::$standard,
  1735. 'userId' => $item['uid'],
  1736. 'useShop' => $value['useShop'],
  1737. 'customerId' => $item['cId'],
  1738. 'source' => $value['grantType'],
  1739. 'createTime' => time(),
  1740. 'updateTime' => time(),
  1741. 'customerIds' => $value['customerIds'],
  1742. 'isMutex' => isset($value['isMutex']) ? $value['isMutex'] : StatusCode::$standard,
  1743. ];
  1744. }
  1745. }
  1746. }
  1747. print_r($insert);
  1748. die;
  1749. }
  1750. public function testKuaiDi100()
  1751. {
  1752. $kuaidi100Config = Factory::config()->get('kuaidi100');
  1753. if (empty($kuaidi100Config) || !isset($kuaidi100Config['customer']) || !isset($kuaidi100Config['key'])) {
  1754. $this->sendOutput('快递100配置错误', ErrorCode::$configEroor);
  1755. }
  1756. $objQuery = new Query($kuaidi100Config['customer'], $kuaidi100Config['key']);
  1757. $kuaidiData = [
  1758. 'com' => 'zhongtong',
  1759. 'num' => '73140775283454',
  1760. 'phone' => 17600105150,
  1761. ];
  1762. $result = $objQuery->pollQuery($kuaidiData);
  1763. if (!$result->isSuccess()) {
  1764. echo $result->getData() . $result->getErrorCode();
  1765. }
  1766. V($result->getData());
  1767. }
  1768. // 快递100查询返回数据内容
  1769. public function msg()
  1770. {
  1771. $str = '{"message":"ok","nu":"3103922659603","ischeck":"1","condition":"D01","com":"yunda","status":"200","state":"3","data":[{"time":"2020-09-01 22:02:08","ftime":"2020-09-01 22:02:08","context":"[陕西西安北郊一公司未央二区寄存点分部]【代收点】您的快件已签收,签收人在【君泰烟酒店(凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收))】领取。"},{"time":"2020-09-01 20:36:29","ftime":"2020-09-01 20:36:29","context":"[陕西西安北郊一公司未央二区寄存点分部]【代收点】您的快件已送达 君泰烟酒店 保管,地址:凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收),请及时领取,如有疑问请电联快递员:韩生斌【13519168931】。"},{"time":"2020-09-01 18:51:13","ftime":"2020-09-01 18:51:13","context":"[陕西西安北郊一公司未央二区寄存点分部]【西安市】陕西西安北郊一公司未央二区寄存点分部 快递员 韩生斌13519168931 正在为您派件【95114/95121/9501395546为韵达快递员外呼专属号码,请放心接听】"},{"time":"2020-09-01 17:50:26","ftime":"2020-09-01 17:50:26","context":"[陕西西安北郊一公司]【西安市】已离开 陕西西安北郊一公司;发往 陕西西安北郊一公司未央二区寄存点分部"},{"time":"2020-09-01 12:52:14","ftime":"2020-09-01 12:52:14","context":"[陕西西安分拨中心]【西安市】已离开 陕西西安分拨中心;发往 陕西西安北郊一公司"},{"time":"2020-09-01 12:45:28","ftime":"2020-09-01 12:45:28","context":"[陕西西安分拨中心]【西安市】已到达 陕西西安分拨中心"},{"time":"2020-08-31 19:51:10","ftime":"2020-08-31 19:51:10","context":"[山东济南分拨中心]【济南市】已离开 山东济南分拨中心;发往 陕西西安地区包"},{"time":"2020-08-31 19:42:34","ftime":"2020-08-31 19:42:34","context":"[山东济南分拨中心]【济南市】已到达 山东济南分拨中心"},{"time":"2020-08-30 10:37:09","ftime":"2020-08-30 10:37:09","context":"[山东市场部鹏程KH分部]【济南市】山东市场部鹏程KH分部 已揽收"}]}';
  1772. V(json_decode($str, true));
  1773. }
  1774. // public function testKDNiao()
  1775. // {
  1776. // $kdniaoConfig = Factory::config()->get('kdniao');
  1777. // if (empty($kdniaoConfig) || !isset($kdniaoConfig['EBusinessID']) || !isset($kdniaoConfig['key'])) {
  1778. // $this->sendOutput('快递100配置错误', ErrorCode::$configEroor);
  1779. // }
  1780. // $objQuery = new KDNiaoQuery($kdniaoConfig['EBusinessID'], $kdniaoConfig['key']);
  1781. //
  1782. // $kuaidiData = [
  1783. // 'com' => 'HTKY',
  1784. // 'num' => '557021498255630',
  1785. // ];
  1786. // $result = $objQuery->EbusinessOrderHandle($kuaidiData);
  1787. // if (!$result->isSuccess()) {
  1788. // parent::sendOutput($result->getData(), $result->getErrorCode());
  1789. // }
  1790. // parent::sendOutput($result->getData());
  1791. // }
  1792. // 快递鸟查询返回数据内容
  1793. public function msg1()
  1794. {
  1795. $str = '{
  1796. "LogisticCode" : "557021498255630",
  1797. "ShipperCode" : "HTKY",
  1798. "Traces" : [ {
  1799. "AcceptStation" : "【太仓】,【扫描壹/13913775727】已揽收",
  1800. "AcceptTime" : "2020-08-30 17:56:19"
  1801. }, {
  1802. "AcceptStation" : "到【上海转运中心】",
  1803. "AcceptTime" : "2020-08-30 21:44:19"
  1804. }, {
  1805. "AcceptStation" : "【上海转运中心】,正发往【西安转运中心】",
  1806. "AcceptTime" : "2020-08-30 21:46:44"
  1807. }, {
  1808. "AcceptStation" : "到【西安转运中心】",
  1809. "AcceptTime" : "2020-09-01 01:32:36"
  1810. }, {
  1811. "AcceptStation" : "【西安转运中心】,正发往【西安北郊一站】",
  1812. "AcceptTime" : "2020-09-01 02:16:14"
  1813. }, {
  1814. "AcceptStation" : "【陈仕友/15229250633】正在派件,【西安北郊一站/网点电话18821713238 029-68569101】",
  1815. "AcceptTime" : "2020-09-01 08:42:50"
  1816. }, {
  1817. "AcceptStation" : "派件送达【兔喜快递超市】君泰烟酒店,请前往凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收)领取您的包裹,联系电话:15309281529",
  1818. "AcceptTime" : "2020-09-01 10:23:10"
  1819. }, {
  1820. "AcceptStation" : "客户已取件,提货点:【兔喜快递超市】 君泰烟酒店(15309281529 凤城一路锦园君逸西区东门斜对面君泰烟酒店(免费代收))",
  1821. "AcceptTime" : "2020-09-01 22:01:48"
  1822. } ],
  1823. "State" : "3",
  1824. "EBusinessID" : "1670600",
  1825. "Success" : true
  1826. }';
  1827. V(json_decode($str, true));
  1828. }
  1829. /**
  1830. * sql执行
  1831. * 该方法只执行需要拼接企业id的表 不要拼接企业id的表请自行手动执行
  1832. */
  1833. public function batchSql()
  1834. {
  1835. $sqlParent = "
  1836. ALTER TABLE `www.qianniao.vip`.`qianniao_staff_1` MODIFY COLUMN `userCenterId` int(11) NULL DEFAULT NULL COMMENT '用户中心id' AFTER `id`, MODIFY COLUMN `departmentId` int(11) NULL DEFAULT NULL COMMENT '部门id' AFTER `userCenterId`, MODIFY COLUMN `balance` decimal(10, 2) NULL COMMENT '余额' AFTER `rule`;
  1837. ";
  1838. //执行语句
  1839. $sql = substr($sqlParent, stripos($sqlParent, "` ") + 2);
  1840. $sqlIndex = $sql;
  1841. //执行语句表所属数据库
  1842. $dbName = substr($sqlParent, stripos($sqlParent, ' `') + 2, stripos($sqlParent, '`.') - stripos($sqlParent, ' `') - 2);
  1843. //企业表所属数据库
  1844. $dbIndexName = 'www.qianniao.vip';
  1845. //库存数据库名
  1846. $stockDbName = 'stock.qianniao.vip';
  1847. //表名
  1848. $sqlTable = substr($sqlParent, stripos($sqlParent, '.`') + 2, stripos($sqlParent, '` ') - stripos($sqlParent, '.`') - 2);
  1849. $tableNameIndex = substr($sqlTable, 0, strripos($sqlTable, '_') + 1);
  1850. //是否执行企业1表
  1851. $oneEnterpriseTable = true;
  1852. //从某个企业执行
  1853. $startEnterpriseId = 0;
  1854. //按照用户人数分表 例:tableName_1_1
  1855. $userByTables = [
  1856. 'qianniao_order_',
  1857. 'qianniao_order_coupon_',
  1858. 'qianniao_order_goods_',
  1859. 'qianniao_order_receive_',
  1860. 'qianniao_goods_collect_',
  1861. ];
  1862. //按照仓库id分表
  1863. $warehouseTable = [
  1864. 'qianniao_inventory_batch_'
  1865. ];
  1866. //按照季度分表 例:tableName_1_2020_3
  1867. $dateByTable = [
  1868. 'qianniao_commission_order_',
  1869. 'qianniao_customerPriceAdjustmentSheet_'
  1870. ];
  1871. //按照季度分表2 例:tableName_1_201
  1872. $dateByTableTwo = [
  1873. 'qianniao_inventory_locking_',
  1874. ];
  1875. //按照仓库id和季度分表 例:tableName_1_1_194
  1876. $warehouseAndDateByTable = [
  1877. 'qianniao_inventory_details_'
  1878. ];
  1879. $runTrue = 0;
  1880. $runFalse = 0;
  1881. $runTrueTableName = [];
  1882. $runFalseTableName = [];
  1883. $tableNum = 0;
  1884. $existNum = 0;
  1885. $existTable = [];
  1886. if (empty($sqlIndex)) {
  1887. exit('请输入sql语句');
  1888. }
  1889. if (empty($dbIndexName)) {
  1890. exit('请输入数据库名');
  1891. }
  1892. if (empty($tableNameIndex)) {
  1893. exit('请输入表名');
  1894. }
  1895. //查询所有企业
  1896. $whereSql = '';
  1897. if ($startEnterpriseId) {
  1898. $whereSql = ' where id >= ' . $startEnterpriseId;
  1899. }
  1900. $sql = 'select id from `' . $dbIndexName . '`.`qianniao_enterprise_1`' . $whereSql;
  1901. $dbResult = $this->objDGoods->query($sql);
  1902. if ($dbResult === false) {
  1903. exit($this->objDGoods->error());
  1904. }
  1905. $enterpriseResult = $dbResult;
  1906. unset($dbResult);
  1907. unset($sql);
  1908. if (empty($enterpriseResult)) {
  1909. self::prompt('企业数据为空', 0, $enterpriseResult, 0, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
  1910. }
  1911. //按人数分表 因为用户数据量小 所以统一后缀加_1
  1912. $tableSuffix = [];
  1913. foreach ($userByTables as $value) {
  1914. if ($tableNameIndex == $value) {
  1915. $tableSuffix[] = '_1';
  1916. break;
  1917. }
  1918. }
  1919. $start = 2020;
  1920. $end = (int)date('Y', time());
  1921. //按日期季度分表
  1922. foreach ($dateByTable as $value) {
  1923. if ($tableNameIndex == $value) {
  1924. for ($ii = $start; $ii <= $end; $ii++) {
  1925. for ($i = 1; $i <= 4; $i++) {
  1926. $tableSuffix[] = '_' . $ii . '_' . $i;
  1927. }
  1928. }
  1929. break;
  1930. }
  1931. }
  1932. //按照季度分表2
  1933. foreach ($dateByTableTwo as $value) {
  1934. if ($tableNameIndex == $value) {
  1935. for ($ii = $start; $ii <= $end; $ii++) {
  1936. for ($i = 1; $i <= 4; $i++) {
  1937. $tableSuffix[] = '_' . substr($ii, -2) . $i;
  1938. }
  1939. }
  1940. break;
  1941. }
  1942. }
  1943. //按日期季度分表 拼接仓库id
  1944. $isWarehouseId = false;
  1945. foreach ($warehouseAndDateByTable as $value) {
  1946. if ($tableNameIndex == $value) {
  1947. $isWarehouseId = true;
  1948. for ($ii = $start; $ii <= $end; $ii++) {
  1949. for ($i = 1; $i <= 4; $i++) {
  1950. $tableSuffix[] = '_' . substr($ii, -2) . $i;
  1951. }
  1952. }
  1953. break;
  1954. }
  1955. }
  1956. //按照仓库id分表
  1957. foreach ($warehouseTable as $value) {
  1958. if ($tableNameIndex == $value) {
  1959. $isWarehouseId = true;
  1960. break;
  1961. }
  1962. }
  1963. if ($isWarehouseId && empty($stockDbName)) {
  1964. exit($tableNameIndex . '按照仓库分表, 请输入仓库表对应数据库名称');
  1965. }
  1966. $enterpriseFormat = array_column($enterpriseResult, null, 'id');
  1967. if (!isset($enterpriseFormat[1])) {
  1968. $enterprise1 = [
  1969. 'id' => 1,
  1970. ];
  1971. array_unshift($enterpriseResult, $enterprise1);
  1972. }
  1973. $enterpriseData = [];
  1974. $emptyTable = [];
  1975. foreach ($enterpriseResult as $value) {
  1976. $tableList = [];
  1977. //拿出企业id
  1978. $enterpriseId = $value['id'];
  1979. //判断是否执行1企业
  1980. if ($enterpriseId == 1) {
  1981. if ($oneEnterpriseTable == false) {
  1982. continue;
  1983. } else {
  1984. if (!empty($tableSuffix)) {
  1985. $tableList[] = $tableNameIndex . $enterpriseId;
  1986. }
  1987. }
  1988. }
  1989. if ($isWarehouseId) {
  1990. //查询仓库的商铺
  1991. $sql = 'select id from `' . $stockDbName . '`.`qianniao_warehouse_' . $enterpriseId . '`';
  1992. $dbResult = $this->objDGoods->query($sql);
  1993. if ($dbResult === false) {
  1994. self::prompt($this->objDGoods->error(), $enterpriseId, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
  1995. }
  1996. $warehouseResult = $dbResult;
  1997. unset($dbResult);
  1998. //循环仓库数据
  1999. foreach ($warehouseResult as $warehouse) {
  2000. $warehouseId = $warehouse['id'];
  2001. //判断是否有日期后缀
  2002. if (!empty($tableSuffix)) {
  2003. foreach ($tableSuffix as $suffix) {
  2004. //拼接表名
  2005. $tableList[] = $tableNameIndex . $enterpriseId . '_' . $warehouseId . $suffix;
  2006. }
  2007. } else {
  2008. $tableList[] = $tableNameIndex . $enterpriseId . '_' . $warehouseId;
  2009. }
  2010. }
  2011. } else {
  2012. //判断是否有日期后缀
  2013. if (!empty($tableSuffix)) {
  2014. foreach ($tableSuffix as $suffix) {
  2015. //拼接表名
  2016. $tableList[] = $tableNameIndex . $enterpriseId . $suffix;
  2017. }
  2018. } else {
  2019. $tableList[] = $tableNameIndex . $enterpriseId;
  2020. }
  2021. }
  2022. foreach ($tableList as $tableName) {
  2023. $tableNum++;
  2024. //查询表是否存在
  2025. $sql = 'select count(TABLE_NAME) as isTable from information_schema.TABLES where TABLE_SCHEMA = "' . $dbName . '" and TABLE_NAME = "' . $tableName . '"';
  2026. $dbResult = $this->objDGoods->query($sql);
  2027. if ($dbResult === false) {
  2028. self::prompt($this->objDGoods->error(), $enterpriseId, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
  2029. }
  2030. $isTable = 0;
  2031. if (!empty($dbResult)) {
  2032. if (isset($dbResult[0]['isTable']) && $dbResult[0]['isTable'] == 1) {
  2033. $isTable = 1;
  2034. }
  2035. }
  2036. unset($dbResult);
  2037. //判断表是否存在
  2038. if ($isTable) {
  2039. $existNum++;
  2040. $existTable[] = $tableName;
  2041. $enterpriseData[$enterpriseId][] = ['enterpriseId' => $enterpriseId, 'tableName' => $tableName];
  2042. } else {
  2043. $emptyTable[] = $tableName;
  2044. }
  2045. }
  2046. }
  2047. // V($existTable);
  2048. // self::prompt('', 0, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
  2049. //执行语句
  2050. foreach ($enterpriseData as $enterpriseId => $value) {
  2051. foreach ($value as $enterprise) {
  2052. $enterpriseId = $enterprise['enterpriseId'];
  2053. $tableName = $enterprise['tableName'];
  2054. //拼接修改sql语句
  2055. $sql = "ALTER TABLE `" . $dbName . "`.`" . $tableName . "` " . $sqlIndex;
  2056. $dbResult = $this->objDGoods->query($sql);
  2057. if ($dbResult === false) {
  2058. $runFalse++;
  2059. $runFalseTableName[] = $tableName;
  2060. self::prompt($this->objDGoods->error(), $enterpriseId, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
  2061. }
  2062. $runTrue++;
  2063. $runTrueTableName[] = $tableName;
  2064. unset($dbResult);
  2065. }
  2066. }
  2067. self::prompt('', 0, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName);
  2068. }
  2069. public function prompt($info = '', $enterpriseId = 0, $enterpriseResult, $tableNum, $existNum, $runTrue, $runFalse, $runTrueTableName, $runFalseTableName)
  2070. {
  2071. $title = '';
  2072. if (!empty($info)) {
  2073. $title = '执行到企业' . $enterpriseId . '时有报错:
  2074. ' . $info . '
  2075. ';
  2076. }
  2077. $title .= '一共' . count($enterpriseResult) . '个企业, 需要修改' . $tableNum . '个表, 存在的表有' . $existNum . '个, 修改成功的表' . $runTrue . '个, 修改失败的表' . $runFalse . '个, 成功的有:' . implode(',', $runTrueTableName) . '; 失败的有:' . implode(',', $runFalseTableName);
  2078. exit($title);
  2079. }
  2080. /**
  2081. * 批量删除某个企业的表
  2082. */
  2083. public function dropEnterpriseTable()
  2084. {
  2085. $date = [];
  2086. for ($i = 2; $i <= 100; $i++) {
  2087. $date[] = $i;
  2088. }
  2089. $sql = 'select id from `www.qianniao.vip`.`qianniao_enterprise_1`';
  2090. $dbResult = $this->objDGoods->query($sql);
  2091. $aa = [];
  2092. foreach ($dbResult as $value) {
  2093. $aa[] = $value['id'];
  2094. }
  2095. $dbResult = array_diff($date, $aa);
  2096. // V($dbResult);
  2097. // $sql = 'select id from `www.qianniao.vip`.`qianniao_enterprise_1` where expireTime <= '.time();
  2098. // $dbResult = $this->objDGoods->query($sql);
  2099. if (empty($dbResult)) {
  2100. exit('没有过期企业');
  2101. }
  2102. $i = 0;
  2103. foreach ($dbResult as $value) {
  2104. $enterpriseId = $value;
  2105. // $enterpriseId = $value['id'];
  2106. $sql = 'DROP TABLE `www.qianniao.vip`.`qianniao_activity_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_activity_goods_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_cart_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_businessman_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_coupon_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_customer_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_customer_contact_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_customer_shipping_address_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_department_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_department_role_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_basic_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_brand_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_category_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_goods_collect_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_material_content_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_message_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_coupon_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_goods_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_index_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_receive_' . $enterpriseId . '_1`, `www.qianniao.vip`.`qianniao_order_return_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_return_details_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_order_statistics_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_page_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_role_acl_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_sku_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_spec_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_staff_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_units_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_user_coupon_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_vip_card_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_vip_card_order_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_allocate_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_allocate_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_batch_' . $enterpriseId . '_1`, `stock.qianniao.vip`.`qianniao_inventory_details_' . $enterpriseId . '_1_203`, `stock.qianniao.vip`.`qianniao_inventory_in_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_in_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_locking_' . $enterpriseId . '_203`, `stock.qianniao.vip`.`qianniao_inventory_out_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_inventory_out_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_goods_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_out_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_purchase_out_goods_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_stocktaking_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_stocktaking_details_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_supplier_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_warehouse_' . $enterpriseId . '`, `stock.qianniao.vip`.`qianniao_warehouse_beginning_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_customerPriceAdjustmentSheet_' . $enterpriseId . '_2020_3`, `price.qianniao.vip`.`qianniao_customerPriceEffective_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_customerTypePriceAdjustmentSheet_' . $enterpriseId . '_2020_3`, `price.qianniao.vip`.`qianniao_customerTypePriceEffective_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_lastEffectiveSalePriceAreaType_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_nationalUnifiedPrice_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_priceAdjustmentSheet_' . $enterpriseId . '_2020_3`, `price.qianniao.vip`.`qianniao_priceRangeSheet_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_account_transfer_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_customer_balance_' . $enterpriseId . '_1`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_customer_balance_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_paid_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_paid_account_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_paid_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_pay_receipt_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_pay_receipt_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_receive_receipt_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_receive_receipt_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_received_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_received_account_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_received_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_supplier_balance_' . $enterpriseId . '_1`, `finance.qianniao.vip`.`qianniao_supplier_balance_detail_' . $enterpriseId . '_2020_3`, `finance.qianniao.vip`.`qianniao_supplier_balance_detail_index_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_supplier_balance_index_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_flow_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_goods_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_goods_statistics_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_order_' . $enterpriseId . '_2020_3`, `www.qianniao.vip`.`qianniao_commission_order_index_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_commission_withdrawals_' . $enterpriseId . '`, `price.qianniao.vip`.`qianniao_priceAdjustmentSheet_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_pay_receipt_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_receive_receipt_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_received_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_received_account_' . $enterpriseId . '_2020_2`, `finance.qianniao.vip`.`qianniao_supplier_balance_detail_' . $enterpriseId . '_2020_2`, `www.qianniao.vip`.`qianniao_common_app_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_delivery_rule_' . $enterpriseId . '`, `www.qianniao.vip`.`qianniao_delivery_self_rule_' . $enterpriseId . '`, `finance.qianniao.vip`.`qianniao_customer_balance_detail_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_account_detail_' . $enterpriseId . '_1`, `finance.qianniao.vip`.`qianniao_paid_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_paid_account_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_pay_receipt_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_receive_receipt_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_received_' . $enterpriseId . '_2020_1`, `finance.qianniao.vip`.`qianniao_received_account_' . $enterpriseId . '_2020_1`, `www.qianniao.vip`.`qianniao_enterprise_template_module_' . $enterpriseId . '`';
  2107. // $enterpriseSql = 'DELETE FROM `www.qianniao.vip`.`qianniao_enterprise_1` WHERE `id` = '.$enterpriseId;
  2108. // $this->objDGoods->query($enterpriseSql);
  2109. $enterpriseBandUserCenterSql = 'DELETE FROM `www.qianniao.vip`.`qianniao_user_bind_enterprise` WHERE `enterpriseId` = ' . $enterpriseId;
  2110. $this->objDGoods->query($enterpriseBandUserCenterSql);
  2111. $this->objDGoods->query($sql);
  2112. $i++;
  2113. }
  2114. exit('执行成功, 共删除' . $i . '个企业');
  2115. }
  2116. // 客如云
  2117. public function keruyun()
  2118. {
  2119. $keruyunConfig = Factory::config()->get('keruyun');
  2120. if (empty($keruyunConfig)) {
  2121. $this->sendOutput('客如云配置错误', ErrorCode::$configEroor);
  2122. }
  2123. $objOpen = new Open($keruyunConfig['shopIdenty'], $keruyunConfig['appKey'], $keruyunConfig['secretKey']);
  2124. $result = $objOpen->getToken();
  2125. if (!$result->isSuccess()) {
  2126. echo($result->getData() . $result->getErrorCode());
  2127. }
  2128. $token = $result->getData();
  2129. /*
  2130. unset($result);
  2131. $result = $objOpen->dishMenu($token['token'],1,1);
  2132. if(!$result->isSuccess()){
  2133. echo($result->getData().$result->getErrorCode());
  2134. }
  2135. $goodsData = $result->getData();*/
  2136. /*
  2137. unset($result);
  2138. $result = $objOpen->dishMenuByIds($token['token'], ['245842575890634752']);
  2139. if(!$result->isSuccess()){
  2140. echo($result->getData().$result->getErrorCode());
  2141. }
  2142. $goodsData = $result->getData();V($goodsData);*/
  2143. /*
  2144. $customerData = [
  2145. 'birthday' => time(), // 生日时间戳
  2146. 'loginId' => '17600105150', // 手机号或者微信id
  2147. 'loginType' => 0,
  2148. 'name' => '刘鑫',
  2149. 'sex' => -1,
  2150. ];
  2151. unset($result);
  2152. $result = $objOpen->createCustomer($token['token'], $customerData);
  2153. if(!$result->isSuccess()){
  2154. echo($result->getData().$result->getErrorCode());
  2155. }
  2156. $customerInfo = $result->getData(); V($customerInfo);*/
  2157. /*
  2158. $customerData = [
  2159. 'birthday' => time(), // 生日时间戳
  2160. 'loginId' => '17600105150', // 手机号或者微信id
  2161. 'loginType' => 0,
  2162. 'name' => '刘鑫',
  2163. 'sex' => -1,
  2164. ];
  2165. unset($result);
  2166. $result = $objOpen->createOrUpgradeMember($token['token'], $customerData);
  2167. if(!$result->isSuccess()){
  2168. echo($result->getData().$result->getErrorCode());
  2169. }
  2170. $customerInfo = $result->getData(); V($customerInfo); */
  2171. unset($result);
  2172. $result = $objOpen->login($token['token'], '18992853313');
  2173. if (!$result->isSuccess()) {
  2174. echo($result->getData() . $result->getErrorCode());
  2175. }
  2176. $customerInfo = $result->getData();
  2177. V($customerInfo);
  2178. /*
  2179. unset($result);
  2180. $result = $objOpen->getCustomerDetailById($token['token'], 402153925286827008);
  2181. if(!$result->isSuccess()){
  2182. echo($result->getData().$result->getErrorCode());
  2183. }
  2184. $customerInfo = $result->getData(); V($customerInfo);*/
  2185. /*
  2186. unset($result);
  2187. $result = $objOpen->recharge($token['token'], ['customerId'=>'402153925286827008','amount'=>10000,'tpOrderId'=>'3120200910727']);
  2188. if(!$result->isSuccess()){
  2189. echo($result->getData().$result->getErrorCode());
  2190. }
  2191. $customerInfo = $result->getData(); V($customerInfo);*/
  2192. /*
  2193. unset($result);
  2194. $result = $objOpen->orderExportDetail($token['token'], ['401332262188390400']);
  2195. if(!$result->isSuccess()){
  2196. echo($result->getData().$result->getErrorCode());
  2197. }
  2198. $customerInfo = $result->getData(); V($customerInfo);*/
  2199. /*
  2200. unset($result);
  2201. $result = $objOpen->dinnerOrderDetail($token['token'], 'b28e5f7529ac4c64b04a39104429ef26');
  2202. if(!$result->isSuccess()){
  2203. echo($result->getData().$result->getErrorCode());
  2204. }
  2205. $customerInfo = $result->getData(); V($customerInfo);*/
  2206. /*
  2207. unset($result);
  2208. $result = $objOpen->cancel($token['token'], 'f52b36b49c304823b6fcb3b8f3a934df');
  2209. if(!$result->isSuccess()){
  2210. echo($result->getData().$result->getErrorCode());
  2211. }
  2212. $customerInfo = $result->getData(); V($customerInfo);*/
  2213. /*
  2214. $orderData = [
  2215. 'tpOrderId' => '31202009107241774406',
  2216. 'createTime' => time(),
  2217. 'updateTime' => time(),
  2218. 'payment' => [
  2219. 'memberId' => 402153925286827008,
  2220. 'memberPassword' => md5('105150'),
  2221. 'payType' => 1, //支付方式 1:会员卡余额 2:优惠券 3:订单来源支付
  2222. 'platformDiscountFee' => 0,
  2223. 'serviceFee' => 0,
  2224. 'shopDiscountFee' => 0,
  2225. 'shopFee' => 1,
  2226. 'totalDiscountFee' => 0,
  2227. 'totalFee' => 1,
  2228. 'userFee' => 1
  2229. ],
  2230. 'peopleCount' => 1, // 就餐人数
  2231. 'print' => 1, // 打印
  2232. 'remark' => '小程序订单', // 备注
  2233. 'status' => 2, // 已经确认
  2234. 'shopIdenty' => $keruyunConfig['shopIdenty'],
  2235. 'shopName' => '千鸟云商',
  2236. 'products' => [[
  2237. 'tpId' => 40740829341443072,
  2238. 'name' => '水煮牛肉',
  2239. 'price' => 1,
  2240. 'type' => 0,
  2241. 'unit' => '件',
  2242. 'quantity' => 1,
  2243. 'totalFee' => 1
  2244. ]],
  2245. 'customers' => [
  2246. 'phoneNumber' => '17600105150',
  2247. 'name' => '刘鑫',
  2248. 'gender' => 1,
  2249. ],
  2250. 'totalPrice' => 1,
  2251. ];
  2252. unset($result);
  2253. $result = $objOpen->createSnackOrder($token['token'], $orderData);
  2254. if(!$result->isSuccess()){
  2255. echo($result->getData().$result->getErrorCode());
  2256. }
  2257. $customerInfo = $result->getData(); V($customerInfo); */
  2258. $orderData = [
  2259. 'tpOrderId' => '31202009107241774406',
  2260. 'tpShopId' => 100,
  2261. 'createTime' => time(),
  2262. 'shopName' => '千鸟云商',
  2263. 'products' => [[
  2264. 'name' => '水煮牛肉',
  2265. 'type' => 0,
  2266. 'tpId' => 40740829341443072,
  2267. 'quantity' => 1, // 商品数量
  2268. 'price' => 1, // 商品单价
  2269. 'unit' => '件',
  2270. 'packagePrice' => 0, // 餐盒单价
  2271. 'packageQuantity' => 0, // 餐盒数量
  2272. 'totalFee' => 1 // 商品总金额
  2273. ]],
  2274. 'delivery' => [
  2275. 'expectTime' => 0, // 期望送达时间
  2276. 'deliveryParty' => 1, // 配送方式
  2277. 'receiverName' => '刘鑫', // 收货人姓名
  2278. 'receiverPhone' => 17600105150, // 收货人电话
  2279. ],
  2280. 'payment' => [
  2281. 'totalFee' => 1, // 订单总价=商品总金额+餐盒费+配送费
  2282. 'deliveryFee' => 0, // 配送费
  2283. 'packageFee' => 0, // 餐盒费=餐盒数量 * 餐盒单价
  2284. 'discountFee' => 0, // 优惠总金额=平台优惠总金额+商户优惠总金额
  2285. 'platformDiscountFee' => 0, // 平台优惠总金额
  2286. 'shopDiscountFee' => 0, // 商家优惠
  2287. 'shopFee' => 1, // 商户实收总价
  2288. 'userFee' => 1, // 用户实付=订单总价-优惠总金额
  2289. 'serviceFee' => 0, // 服务费(商户向平台支付的佣金等)
  2290. 'subsidies' => 0, // 平台补贴
  2291. 'payType' => 3, // 支付方式 1:线下支付/货到付款 2:在线支付 4:优惠券 3:会员卡余额
  2292. 'memberId' => 402153925286827008,
  2293. 'memberPassword' => md5('105150'),
  2294. ],
  2295. 'customers' => [
  2296. 'phoneNumber' => '17600105150', // 会员电话
  2297. 'name' => '刘鑫', // 会员名字
  2298. 'gender' => 1, // 会员性别
  2299. ]
  2300. ];
  2301. unset($result);
  2302. $result = $objOpen->createTakeoutOrder($token['token'], $orderData);
  2303. if (!$result->isSuccess()) {
  2304. echo($result->getData() . $result->getErrorCode());
  2305. }
  2306. $customerInfo = $result->getData();
  2307. V($customerInfo);
  2308. }
  2309. /**
  2310. * 客如云菜品变更通知
  2311. */
  2312. public function dishChaangeNotify()
  2313. {
  2314. $postStr = file_get_contents('php://input');
  2315. file_put_contents('/www/wwwroot/logs/api.junhailan.com/keruyun.log', date('Y-m-d H:i:s') . '回调数据' . var_export($postStr, true) . PHP_EOL, FILE_APPEND);
  2316. }
  2317. /**
  2318. * 测试发布订阅消息
  2319. */
  2320. public function subscribeMessageSend()
  2321. {
  2322. $miniprogramConfigData = Factory::config()->getAppoint('weixin', 'miniprogram');
  2323. if (empty($miniprogramConfigData)) {
  2324. echo('小程序配置项错误');
  2325. exit();
  2326. }
  2327. // 获取access_token
  2328. $objOffiaccount = new Offiaccount($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
  2329. $result = $objOffiaccount->token();
  2330. if (!$result->isSuccess()) {
  2331. echo $result->getData(), $result->getErrorCode();
  2332. }
  2333. $access_token = $result->getData();
  2334. unset($result);
  2335. // 发送订阅消息
  2336. $data = [
  2337. 'name1' => [
  2338. 'value' => '千鸟云商店铺',
  2339. ],
  2340. 'date2' => [
  2341. 'value' => '2020年10月27日',
  2342. ],
  2343. 'amount3' => [
  2344. 'value' => '¥100元',
  2345. ],
  2346. 'character_string4' => [
  2347. 'value' => '31202010273559779663',
  2348. ],
  2349. ];
  2350. $objMiniprogram = new Miniprogram($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
  2351. $result = $objMiniprogram->subscribeMessageSend($access_token, '7h2cBfuDxPPxovL3xGj9SLojcrVJGNHEzd8OcCUukq4', 'oISU64zx81Uq4oc_kzz1wg4PSNs8', '/pages/index/index', $data);
  2352. V($result);
  2353. }
  2354. /**
  2355. * 添加模板
  2356. */
  2357. public function addtemplate()
  2358. {
  2359. $miniprogramConfigData = Factory::config()->getAppoint('weixin', 'miniprogram');
  2360. if (empty($miniprogramConfigData)) {
  2361. echo('小程序配置项错误');
  2362. exit();
  2363. }
  2364. // 获取access_token
  2365. $objOffiaccount = new Offiaccount($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
  2366. $result = $objOffiaccount->token();
  2367. if (!$result->isSuccess()) {
  2368. echo $result->getData(), $result->getErrorCode();
  2369. }
  2370. $access_token = $result->getData();
  2371. unset($result);
  2372. $objMiniprogram = new Miniprogram($miniprogramConfigData['appid'], $miniprogramConfigData['appSecret']);
  2373. $result = $objMiniprogram->addtemplate($access_token, '3637', [2, 3, 8, 10], '发货通知');
  2374. V($result);
  2375. }
  2376. public function webstockConnect()
  2377. {
  2378. $swooleServerConfigData = Factory::config()->getAppoint('swooleServer', 'order');
  2379. if (empty($swooleServerConfigData)) {
  2380. echo('swoole服务端链接信息配置项错误');
  2381. exit();
  2382. }
  2383. $swooleClient = Factory::swoole($swooleServerConfigData, 'WebsocketClient');
  2384. // 触发商家新订单通知
  2385. $data = [
  2386. 'controller' => 'NewOrder',
  2387. 'action' => 'createConnect',
  2388. 'params' => [
  2389. 'platfrom' => 'qianniaoSAAS',
  2390. 'shop_id' => 1,
  2391. 'userId' => 200,
  2392. ]
  2393. ];
  2394. $swooleClient->sendJson($data);
  2395. V($swooleClient->recv());
  2396. }
  2397. public function test1()
  2398. {
  2399. $obj = new MBaseModel(1, 1);
  2400. V($obj->sendMessage(1, 'NewOrder', 'order'));
  2401. }
  2402. /**
  2403. * 测试下webstock
  2404. * @throws \Exception
  2405. */
  2406. public function webstock()
  2407. {
  2408. $swooleServerConfigData = Factory::config()->getAppoint('swooleServer', 'order');
  2409. if (empty($swooleServerConfigData)) {
  2410. echo('swoole服务端链接信息配置项错误');
  2411. exit();
  2412. }
  2413. $swooleClient = Factory::swoole($swooleServerConfigData, 'WebsocketClient');
  2414. // 触发商家新订单通知
  2415. $data = [
  2416. 'controller' => 'NewOrder',
  2417. 'action' => 'autoSend',
  2418. 'params' => [
  2419. 'platfrom' => 'qianniaoSAAS',
  2420. 'shop_id' => 9,
  2421. ]
  2422. ];
  2423. $swooleClient->sendJson($data);
  2424. V($swooleClient->recv());
  2425. }
  2426. /**
  2427. * 达达配送接口
  2428. */
  2429. public function dada()
  2430. {
  2431. $dataConfigData = Factory::config()->get('dada');
  2432. if (empty($dataConfigData)) {
  2433. echo('达达配送配置项错误');
  2434. exit();
  2435. }
  2436. $objMerchant = new Merchant($dataConfigData['app_key'], $dataConfigData['app_secret'], 73753);
  2437. $reuslt = $objMerchant->cityCodeList();
  2438. V($reuslt->getData());
  2439. }
  2440. /**
  2441. * 测试退款
  2442. */
  2443. public function refund()
  2444. {
  2445. $miniprogramConfigData = Factory::config()->get('weixin');
  2446. if (empty($miniprogramConfigData)) {
  2447. echo('小程序配置项错误');
  2448. exit();
  2449. }
  2450. $objPay =new Pay($miniprogramConfigData['miniprogram']['appid'], $miniprogramConfigData['pay']['mch_id'],$miniprogramConfigData['pay']['apiPartnerKey'] );
  2451. V($objPay->transfers('4200000989202104119581846831', '20210411-0009','0.01','0.01'));
  2452. }
  2453. /**
  2454. * 临时财务脚本解决应收单索引表id重复问题
  2455. */
  2456. public function tmp()
  2457. {
  2458. $objMReceive = new MReceive(64, 1);
  2459. $result = $objMReceive->tmp();
  2460. if ($result->isSuccess()) {
  2461. V($result->getData());
  2462. } else {
  2463. V($result->getData(), $result->getErrorCode());
  2464. }
  2465. }
  2466. /**
  2467. * 临时财务脚本解决应付表索引表id重复问题
  2468. */
  2469. public function tmp1()
  2470. {
  2471. $objMPay = new MPay(64, 1);
  2472. $result = $objMPay->tmp1();
  2473. if ($result->isSuccess()) {
  2474. V($result->getData());
  2475. } else {
  2476. V($result->getData(), $result->getErrorCode());
  2477. }
  2478. }
  2479. }