handleCxData.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. <?php
  2. namespace app\command;
  3. use think\console\Command;
  4. use think\console\Input;
  5. use think\console\Output;
  6. use think\Exception;
  7. use think\facade\Db;
  8. use think\facade\Cache;
  9. //将cfp_caixiao_data里面的数据,分别处理到cfp_qrd_info,cfp_cgd_info(若未对账),或者cfp_caixiao_wait(已对账)
  10. class handleCxData extends command
  11. {
  12. private $interval = 15000 * 60;//执行间隔,单位:分(每次同步前5分钟的数据)
  13. protected function configure()
  14. {
  15. parent::configure(); // TODO: Change the autogenerated stub
  16. $this->setName('handleCxData')->setDescription('处理中间表的采销数据');
  17. }
  18. protected function execute(Input $input, Output $output)
  19. {
  20. $date = date('Y-m-d H:i:s');
  21. $goodset =Cache::store("redis")->get("JsHandle");
  22. if($goodset ==1) return;
  23. Cache::store("redis")->set("JsHandle",1,180);
  24. Db::startTrans();
  25. $results = Db::name('caixiao_data')
  26. ->withAttr("data",function ($v){
  27. return json_decode(str_replace(array("\r\n", "\r", "\n"), '', $v),true);
  28. })
  29. ->where("status",1)
  30. ->where("addtime",">=",date("Y-m-d H:i:s",strtotime(time()-1800)))
  31. ->lock(true)
  32. ->limit(100)
  33. ->select()->toArray();
  34. if ($results) {
  35. try {
  36. foreach ($results as $result) {
  37. $data=$result['data'] ?? [];
  38. $qrd_insert_data=$wait_insert_data=$cgd_insert_data=[];
  39. $data['cat_name']=is_array($data['cat_name']) ? $data['cat_name'] : json_decode($data['cat_name'] ,
  40. true
  41. );
  42. if ($result['order_type'] == 1) {
  43. $data['total_price']=$data['total_price'] - $data['th_fee'] - $data['diff_fee'];
  44. $exitReport=Db::name("report_code")->where('qrdNo' , $data['orderCode'])->findOrEmpty();
  45. $repostinsert=[
  46. "qrdNo"=>$data['orderCode'] ,
  47. "seller_id"=>$data['apply_id'] ,
  48. "seller"=>$data['apply_name'] ,
  49. "customerName"=>$data['customer_name'] ,
  50. "customerNo"=>$data['customer_code'] ,
  51. "companyNo"=>$data['supplierNo'] ,
  52. "companyName"=>$data['supplier_name'] ,
  53. "cgdNo"=>$data['cgdNo'] ,
  54. ];
  55. if (empty($exitReport)) Db::name("report_code")->insert($repostinsert);
  56. else Db::name("report_code")->where($exitReport)->update($repostinsert);
  57. $exists_qrd=Db::name('qrd_info')
  58. ->whereIn('sequenceNo' , $data['orderCode'])
  59. ->field('id,status')->findOrEmpty();
  60. $all_branch=Db::name('customer_info')
  61. ->whereIn('companyNo' , $data['customer_code'])
  62. ->column('branch,parent' , 'companyNo');
  63. //已存在
  64. if (!empty($exists_qrd)) {
  65. if ($exists_qrd['status'] == 0) {
  66. $report=[
  67. "qrdNo"=>$data['orderCode'] ,
  68. "seller_id"=>$data['apply_id'] ,
  69. "seller"=>$data['apply_name'] ,
  70. "customerName"=>$data['customer_name'] ,
  71. "customerNo"=>$data['customer_code'] ,
  72. "companyNo"=>$data['supplierNo'] ,
  73. "companyName"=>$data['supplier_name'] ,
  74. "cgdNo"=>$data['cgdNo'] ,
  75. ];
  76. $re=Db::name('qrd_info')
  77. ->where('id' , $exists_qrd['id'])
  78. ->update([
  79. 'name'=>$data['orderCode'] ,//确认单名称,
  80. 'sequenceNo'=>$data['orderCode'] ,//确认单编号,
  81. 'ownerName'=>$data['apply_name'] ,//销售员,
  82. 'ownerid'=>$data['apply_id'] ,//销售员id,
  83. 'department'=>$data['depart'] ,//部门,
  84. 'createdTime'=>$data['addtime'] ,//销售单创建时间,
  85. 'qrdType'=>$data['order_type'] ,//销售单类型,
  86. 'qrdSource'=>$data['order_source'] ,//销售单来源,
  87. 'companyNo'=>$data['supplierNo'] ,//业务企业编号,
  88. 'companyName'=>$data['supplier_name'] ,//业务企业名称,
  89. 'customerNo'=>$data['customer_code'] ,//客户编号,
  90. 'customerName'=>$data['customer_name'] ,//客户名称,
  91. 'poCode'=>$data['poNo'] ,//po编号,
  92. 'platName'=>$data['platform_id'] ,//平台名称,
  93. 'workCode'=>$data['workNo'] ,//业务编号,
  94. 'zxCode'=>$data['zxNo'] ,//咨询单编号,
  95. 'goodNo'=>$data['good_code'] ,//商品编号,
  96. 'goodName'=>$data['good_name'] ,//商品名称,
  97. 'goodBrand'=>$data['brand'] ,//商品品牌,
  98. 'firstCat'=>$data['cat_name'][0]['cat_name'] ?? "" ,//一级分类,
  99. 'secCat'=>$data['cat_name'][1]['cat_name'] ?? "" ,//二级分类,
  100. 'thirdCat'=>$data['cat_name'][2]['cat_name'] ?? "" ,//三级分类,
  101. 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类详情,
  102. 'fundCode'=>$data['cat_name'][2]['fund_code'] ?? "" ,//核算编码,
  103. 'goodMaterial'=>'' ,//商品材质,
  104. 'goodUnit'=>$data['unit'] ,//商品单位,
  105. 'goodDesc'=>$data['cost_desc'] ,//工艺说明,
  106. 'goodType'=>$data['good_type'] ,//商品类型,
  107. 'goodModel'=>'' ,//商品型号,
  108. 'isStock'=>$data['is_stock'] ,//是否库存品,
  109. 'metalsType'=>$data['noble_metal'] ,//贵金属种类,
  110. 'weight'=>$data['good_weight'] ,//商品重量,
  111. 'goldPrice'=>$data['gold_price'] ,//贵金属单价,
  112. 'deliveryDay'=>$data['delivery_day'] ,//物流天数,
  113. 'workDay'=>$data['lead_time'] ,//工期,
  114. 'tax'=>$data['tax'] ,//税率,
  115. 'goodNum'=>$data['good_num'] ,//销售数量,
  116. 'goodPrice'=>$data['sale_price'] ,//产品单价,
  117. 'totalPrice'=>$data['total_price'] ,//货款总额,
  118. 'total_origin_price'=>$data['total_origin_price'] ,//成本总额,
  119. 'sendNum'=>$data['send_num'] ,//已发货数量,
  120. 'wsendNum'=>$data['wsend_num'] ,//未发货数量,
  121. 'apay_fee'=>0 ,//已付款,
  122. 'pay_fee'=>0 ,//付款中
  123. 'wpay_fee'=>$data['total_price'] ,//未付款,
  124. 'inv_fee'=>0 ,//回票中
  125. 'ainv_fee'=>0 ,//已开票,
  126. 'winv_fee'=>$data['total_price'] ,//未开票,
  127. 'is_diff'=>$data['is_diff'] ,//是否有工差,
  128. 'sendType'=>$data['send_type'] ,//发货方式,
  129. 'sendStatus'=>$data['send_status'] ,//发货状态,
  130. 'pay_status'=>$data['total_price'] == 0 ? 3 : 1 ,//收款状态,1未付,2部分,3完结
  131. 'inv_status'=>$data['total_price'] == 0 ? 3 : 1 ,//开票状态,,1未付,2部分,3完结
  132. 'remark'=>"" ,//备注,
  133. 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
  134. 'diff_weight'=>$data['diff_weight'] ,//工差重量,
  135. 'diff_fee'=>$data['diff_fee'] ,//工差金额,
  136. 'area'=>$data['customer_name'] ,//公司,
  137. 'customerAttr'=>$all_branch[$data['customer_code']]['parent'] ?? '' ,//客户属性,
  138. 'branch'=>$all_branch[$data['customer_code']]['branch'] ?? '' ,//分公司,从客户表中查
  139. 'cgdNo'=>$data['cgdNo'] ,//采购单号,
  140. 'thNum'=>$data['th_num'] ,//退货数量,
  141. 'th_fee'=>$data['th_fee'] ,//退货金额,
  142. 'pay_source'=>$data['pay_source'] ?? "" ,//支付渠道,
  143. 'is_del'=>0 ,//是否删除,
  144. 'addtime'=>$date ,
  145. 'updatetime'=>$date ,
  146. 'inv_tag'=>0 ,//开票标签,
  147. 'pay_tag'=>0 ,//回款标签,
  148. 'inv_tag_fee'=>0 ,//开票票标签金额,
  149. 'pay_tag_fee'=>0 ,//回款标签金额,
  150. ]
  151. );
  152. } else {
  153. $wait_insert_data=[
  154. "order_type"=>$result['order_type'] ,
  155. "data"=>json_encode($result['data'] , JSON_UNESCAPED_UNICODE) ,
  156. "orderCode"=>$data['orderCode'] ,
  157. "status"=>1 ,
  158. ];
  159. }
  160. } else {
  161. //新增
  162. $qrd_insert_data[]=[
  163. 'name'=>$data['orderCode'] ,//确认单名称,
  164. 'sequenceNo'=>$data['orderCode'] ,//确认单编号,
  165. 'ownerName'=>$data['apply_name'] ,//销售员,
  166. 'ownerid'=>$data['apply_id'] ,//销售员id,
  167. 'department'=>$data['depart'] ,//部门,
  168. 'createdTime'=>$data['addtime'] ,//销售单创建时间,
  169. 'qrdType'=>$data['order_type'] ,//销售单类型,
  170. 'qrdSource'=>$data['order_source'] ,//销售单来源,
  171. 'companyNo'=>$data['supplierNo'] ,//业务企业编号,
  172. 'companyName'=>$data['supplier_name'] ,//业务企业名称,
  173. 'customerNo'=>$data['customer_code'] ,//客户编号,
  174. 'customerName'=>$data['customer_name'] ,//客户名称,
  175. 'poCode'=>$data['poNo'] ,//po编号,
  176. 'platName'=>$data['platform_id'] ,//平台名称,
  177. 'workCode'=>$data['workNo'] ,//业务编号,
  178. 'zxCode'=>$data['zxNo'] ,//咨询单编号,
  179. 'goodNo'=>$data['good_code'] ,//商品编号,
  180. 'goodName'=>$data['good_name'] ,//商品名称,
  181. 'goodBrand'=>$data['brand'] ,//商品品牌,
  182. 'firstCat'=>$data['cat_name'][0]['cat_name'] ?? "" ,//一级分类,
  183. 'secCat'=>$data['cat_name'][1]['cat_name'] ?? "" ,//二级分类,
  184. 'thirdCat'=>$data['cat_name'][2]['cat_name'] ?? "" ,//三级分类,
  185. 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类详情,
  186. 'fundCode'=>$data['cat_name'][2]['fund_code'] ?? "" ,//核算编码,
  187. 'goodMaterial'=>'' ,//商品材质,
  188. 'goodUnit'=>$data['unit'] ,//商品单位,
  189. 'goodDesc'=>$data['cost_desc'] ,//工艺说明,
  190. 'goodType'=>$data['good_type'] ,//商品类型,
  191. 'goodModel'=>'' ,//商品型号,
  192. 'isStock'=>$data['is_stock'] ,//是否库存品,
  193. 'metalsType'=>$data['noble_metal'] ,//贵金属种类,
  194. 'weight'=>$data['good_weight'] ,//商品重量,
  195. 'goldPrice'=>$data['gold_price'] ,//贵金属单价,
  196. 'deliveryDay'=>$data['delivery_day'] ,//物流天数,
  197. 'workDay'=>$data['lead_time'] ,//工期,
  198. 'tax'=>$data['tax'] ,//税率,
  199. 'goodNum'=>$data['good_num'] ,//销售数量,
  200. 'goodPrice'=>$data['sale_price'] ,//产品单价,
  201. 'totalPrice'=>$data['total_price'] ,//货款总额,
  202. 'total_origin_price'=>$data['total_origin_price'] ,//成本总额,
  203. 'sendNum'=>$data['send_num'] ,//已发货数量,
  204. 'wsendNum'=>$data['wsend_num'] ,//未发货数量,
  205. 'apay_fee'=>0 ,//已付款,
  206. 'pay_fee'=>0 ,//付款中
  207. 'wpay_fee'=>$data['total_price'] ,//未付款,
  208. 'inv_fee'=>0 ,//回票中
  209. 'ainv_fee'=>0 ,//已开票,
  210. 'winv_fee'=>$data['total_price'] ,//未开票,
  211. 'is_diff'=>$data['is_diff'] ,//是否有工差,
  212. 'sendType'=>$data['send_type'] ,//发货方式,
  213. 'sendStatus'=>$data['send_status'] ,//发货状态,
  214. 'pay_status'=>$data['total_price'] == 0 ? 3 : 1 ,//收款状态,1未付,2部分,3完结
  215. 'inv_status'=>$data['total_price'] == 0 ? 3 : 1 ,//开票状态,,1未付,2部分,3完结
  216. 'remark'=>"" ,//备注,
  217. 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
  218. 'diff_weight'=>$data['diff_weight'] ,//工差重量,
  219. 'diff_fee'=>$data['diff_fee'] ,//工差金额,
  220. 'area'=>$data['customer_name'] ,//公司,
  221. 'customerAttr'=>$all_branch[$data['customer_code']]['parent'] ,//客户属性,
  222. 'branch'=>$all_branch[$data['customer_code']]['branch'] ?? '' ,//分公司,从客户表中查
  223. 'cgdNo'=>$data['cgdNo'] ,//采购单号,
  224. 'thNum'=>$data['th_num'] ,//退货数量,
  225. 'th_fee'=>$data['th_fee'] ,//退货金额,
  226. 'pay_source'=>$data['pay_source'] ?? "" ,//支付渠道,
  227. 'is_del'=>0 ,//是否删除,
  228. 'addtime'=>$date ,
  229. 'updatetime'=>$date ,
  230. 'inv_tag'=>0 ,//开票标签,
  231. 'pay_tag'=>0 ,//回款标签,
  232. 'inv_tag_fee'=>0 ,//开票票标签金额,
  233. 'pay_tag_fee'=>0 ,//回款标签金额,
  234. ];
  235. }
  236. } else {
  237. //已存在
  238. $data['total_fee']=$data['total_fee'] - $data['th_fee'] - $data['diff_fee'];
  239. $exitReport=Db::name("report_code")->where('cgdNo' , $data['cgdNo'])->findOrEmpty();
  240. $repostinsert=[
  241. "qrdNo"=>$data['qrdNo'] ,
  242. "cgder_id"=>$data['cgder_id'] ,
  243. "cgder"=>$data['cgder'] ,
  244. "supplierName"=>$data['supplier_name'] ,
  245. "supplierNo"=>$data['supplierNo'] ,
  246. "companyNo"=>$data['companyNo'] ,
  247. "companyName"=>$data['companyName'] ,
  248. "cgdNo"=>$data['cgdNo'] ,
  249. ];
  250. if (empty($exitReport)) Db::name("report_code")->insert($repostinsert);
  251. else Db::name("report_code")->where($exitReport)->update($repostinsert);
  252. $exists_cgd=Db::name('cgd_info')
  253. ->whereIn('sequenceNo' , $data['cgdNo'])
  254. ->field('id,status')->findOrEmpty();
  255. if (!empty($exists_cgd)) {
  256. //未对账,更新
  257. if ($exists_cgd['status'] == 0) {
  258. Db::name('cgd_info')
  259. ->where('id' , $exists_cgd['id'])
  260. ->update([
  261. 'name'=>$data['cgdNo'] ,//采购单名称',
  262. 'sequenceNo'=>$data['cgdNo'] ,//采购单编号',
  263. 'ownerName'=>$data['cgder'] ,//采购员名称',
  264. 'ownerid'=>$data['cgder_id'] ,//采购员id',
  265. 'department'=>$data['depart'] ,//部门名称',
  266. 'createdTime'=>$data['addtime'] ,//订单创建时间',
  267. 'cgdType'=>$data['order_type'] ,//采购单类型',
  268. 'cgdSource'=>$data['order_source'] ,//采购单来源',
  269. 'companyNo'=>$data['companyNo'] ,//业务公司编号',
  270. 'companyName'=>$data['companyName'] ,//业务公司',
  271. 'cgdTime'=>$data['addtime'] ,//采购下单时间',
  272. 'bkCode'=>$data['bkcode'] ,//备库单编号',
  273. 'qrdCode'=>$data['qrdNo'] ,//确认单编号',
  274. 'goodNo'=>$data['spuCode'] ,//商品编号',
  275. 'goodName'=>$data['good_name'] ,//商品名称',
  276. 'goodType'=>$data['good_type'] ,//商品类型',
  277. 'goodBrand'=>$data['brand'] ,//商品品牌',
  278. 'goodModel'=>'' ,//商品型号',
  279. 'firstCat'=>$data['cat_name'][0]['cat_name'] ,//商品一级分类',
  280. 'secCat'=>$data['cat_name'][1]['cat_name'] ,//二级分类',
  281. 'thirdCat'=>$data['cat_name'][2]['cat_name'] ,//三级分类',
  282. 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类明细',
  283. 'fundCode'=>$data['cat_name'][2]['fund_code'] ,//NOT NULL,
  284. 'goodMaterial'=>'' ,//商品材质',
  285. 'goodUnit'=>$data['unit'] ,//商品单位',
  286. 'goodDesc'=>$data['cost_desc'] ,//工艺说明',
  287. 'metalsType'=>$data['noble_metal'] ,//贵金属种类',
  288. 'weight'=>$data['weight'] ,//商品重量',
  289. 'goldPrice'=>$data['gold_price'] ,//贵金属实时金价',
  290. 'is_diff'=>$data['is_diff'] ,//是否有工差',
  291. 'deliveryDay'=>$data['delivery_day'] ,//物流天数',
  292. 'workDay'=>$data['lead_time'] ,//产品工期',
  293. 'tax'=>$data['tax'] ,//税点',
  294. 'barePrice'=>$data['nake_fee'] ,//裸价',
  295. 'markPrice'=>$data['mark_fee'] ,//加标费',
  296. 'packPrice'=>$data['pakage_fee'] ,//包装费',
  297. 'certPrice'=>$data['cert_fee'] ,//证书费',
  298. 'openPrice'=>$data['open_fee'] ,//开模费',
  299. 'costPrice'=>$data['teach_fee'] ,//工艺费',
  300. 'deliveryPrice'=>$data['delivery_fee'] ,//物流费',
  301. 'goodPrice'=>$data['good_price'] ,//成本合计/单价',
  302. 'isStock'=>$data['is_stock'] ,//是否库存品',
  303. 'goodNum'=>$data['good_num'] ,//下单数量',
  304. 'totalPrice'=>$data['total_fee'] ,//采购总货款',
  305. 'supplierNo'=>$data['supplierNo'] ,//供应商编号',
  306. 'supplierName'=>$data['supplier_name'] ,//供应商名称',
  307. 'apay_fee'=>0 ,//已付款金额',
  308. 'wpay_fee'=>$data['total_fee'] ,//未付款金额',
  309. 'ainv_fee'=>0 ,//已开票金额',
  310. 'winv_fee'=>$data['total_fee'] ,//未开票金额',
  311. 'sendType'=>$data['send_type'] ,//发货方式',
  312. 'bkCreater'=>$data['bkcreater'] ,//备库申请人',
  313. 'sendStatus'=>$data['send_status'] ,//发货状态',
  314. 'wsendNum'=>$data['wsend_num'] ,//未发货数量',
  315. 'sendNum'=>$data['send_num'] ,//已发货数量',
  316. 'wareHouse'=>$data['wsm_code'] ,//仓库名称',
  317. 'wsmCode'=>$data['wsm_code'] ,//仓库编号',
  318. 'remark'=>'' ,//备注',
  319. 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
  320. 'pay_status'=>$data['total_fee'] == 0 ? 3 : 1 ,//付款情况',
  321. 'inv_status'=>$data['total_fee'] == 0 ? 3 : 1 ,//开票情况',
  322. 'diff_weight'=>$data['diff_weight'] ,//工差重量',
  323. 'diff_fee'=>$data['diff_fee'] ,//工差金额',
  324. 'thNum'=>$data['th_num'] ,//退货数量',
  325. 'th_fee'=>$data['th_fee'] ,//退货金额',
  326. 'check_rate'=>'' ,//修正后的税率',
  327. 'is_del'=>0 ,
  328. 'addtime'=>$date ,
  329. 'updatetime'=>$date ,
  330. ]
  331. );
  332. } else {
  333. $wait_insert_data=[
  334. "order_type"=>$result['order_type'] ,
  335. "data"=>json_encode($result['data'] , JSON_UNESCAPED_UNICODE) ,
  336. "orderCode"=>$data['cgdNo'] ,
  337. "status"=>1 ,
  338. ];
  339. }
  340. } else {
  341. //新增
  342. $cgd_insert_data[]=[
  343. 'name'=>$data['cgdNo'] ,//采购单名称',
  344. 'sequenceNo'=>$data['cgdNo'] ,//采购单编号',
  345. 'ownerName'=>$data['cgder'] ,//采购员名称',
  346. 'ownerid'=>$data['cgder_id'] ,//采购员id',
  347. 'department'=>$data['depart'] ,//部门名称',
  348. 'createdTime'=>$data['addtime'] ,//订单创建时间',
  349. 'cgdType'=>$data['order_type'] ,//采购单类型',
  350. 'cgdSource'=>$data['order_source'] ,//采购单来源',
  351. 'companyNo'=>$data['companyNo'] ,//业务公司编号',
  352. 'companyName'=>$data['companyName'] ,//业务公司',
  353. 'cgdTime'=>$data['addtime'] ,//采购下单时间',
  354. 'bkCode'=>$data['bkcode'] ,//备库单编号',
  355. 'qrdCode'=>$data['qrdNo'] ,//确认单编号',
  356. 'goodNo'=>$data['spuCode'] ,//商品编号',
  357. 'goodName'=>$data['good_name'] ,//商品名称',
  358. 'goodType'=>$data['good_type'] ,//商品类型',
  359. 'goodBrand'=>$data['brand'] ,//商品品牌',
  360. 'goodModel'=>'' ,//商品型号',
  361. 'firstCat'=>$data['cat_name'][0]['cat_name'] ?? "" ,//商品一级分类',
  362. 'secCat'=>$data['cat_name'][1]['cat_name'] ,//二级分类',
  363. 'thirdCat'=>$data['cat_name'][2]['cat_name'] ,//三级分类',
  364. 'catInfo'=>json_encode($data['cat_name'] , JSON_UNESCAPED_UNICODE) ,//分类明细',
  365. 'fundCode'=>$data['cat_name'][2]['fund_code'] ,//NOT NULL,
  366. 'goodMaterial'=>'' ,//商品材质',
  367. 'goodUnit'=>$data['unit'] ,//商品单位',
  368. 'goodDesc'=>$data['cost_desc'] ,//工艺说明',
  369. 'metalsType'=>$data['noble_metal'] ,//贵金属种类',
  370. 'weight'=>$data['weight'] ,//商品重量',
  371. 'goldPrice'=>$data['gold_price'] ,//贵金属实时金价',
  372. 'is_diff'=>$data['is_diff'] ,//是否有工差',
  373. 'deliveryDay'=>$data['delivery_day'] ,//物流天数',
  374. 'workDay'=>$data['lead_time'] ,//产品工期',
  375. 'tax'=>$data['tax'] ,//税点',
  376. 'barePrice'=>$data['nake_fee'] ,//裸价',
  377. 'markPrice'=>$data['mark_fee'] ,//加标费',
  378. 'packPrice'=>$data['pakage_fee'] ,//包装费',
  379. 'certPrice'=>$data['cert_fee'] ,//证书费',
  380. 'openPrice'=>$data['open_fee'] ,//开模费',
  381. 'costPrice'=>$data['teach_fee'] ,//工艺费',
  382. 'deliveryPrice'=>$data['delivery_fee'] ,//物流费',
  383. 'goodPrice'=>$data['good_price'] ,//成本合计/单价',
  384. 'isStock'=>$data['is_stock'] ,//是否库存品',
  385. 'goodNum'=>$data['good_num'] ,//下单数量',
  386. 'totalPrice'=>$data['total_fee'] ,//采购总货款',
  387. 'supplierNo'=>$data['supplierNo'] ,//供应商编号',
  388. 'supplierName'=>$data['supplier_name'] ,//供应商名称',
  389. 'apay_fee'=>0 ,//已付款金额',
  390. 'wpay_fee'=>$data['total_fee'] ,//未付款金额',
  391. 'ainv_fee'=>0 ,//已开票金额',
  392. 'winv_fee'=>$data['total_fee'] ,//未开票金额',
  393. 'sendType'=>$data['send_type'] ,//发货方式',
  394. 'bkCreater'=>$data['bkcreater'] ,//备库申请人',
  395. 'sendStatus'=>$data['send_status'] ,//发货状态',
  396. 'wsendNum'=>$data['wsend_num'] ,//未发货数量',
  397. 'sendNum'=>$data['send_num'] ,//已发货数量',
  398. 'wareHouse'=>$data['wsm_code'] ,//仓库名称',
  399. 'wsmCode'=>$data['wsm_code'] ,//仓库编号',
  400. 'remark'=>'' ,//备注',
  401. 'pay_status'=>$data['total_fee'] == 0 ? 3 : 1 ,//付款情况',
  402. 'inv_status'=>$data['total_fee'] == 0 ? 3 : 1 ,//开票情况',
  403. 'diff_weight'=>$data['diff_weight'] ,//工差重量',
  404. 'diff_fee'=>$data['diff_fee'] ,//工差金额',
  405. 'thNum'=>$data['th_num'] ,//退货数量',
  406. 'th_fee'=>$data['th_fee'] ,//退货金额',
  407. 'check_rate'=>'' ,//修正后的税率',
  408. 'cxCode'=>$data['oldCode'] ?? "" ,//备注,
  409. 'is_del'=>0 ,
  410. 'addtime'=>$date ,
  411. 'updatetime'=>$date ,
  412. ];
  413. }
  414. }
  415. if ($qrd_insert_data) Db::name('qrd_info')->insertAll($qrd_insert_data);
  416. if ($cgd_insert_data) Db::name('cgd_info')->insertAll($cgd_insert_data);
  417. if ($wait_insert_data) Db::name('caixiao_wait')->insert($wait_insert_data);
  418. Db::name("caixiao_data")->where('uniqkey' , $result['uniqkey'])->update(['status'=>0]);
  419. $output->writeln("[$date]:{$result['id']}处理成功");
  420. } Cache::store("redis")->set("JsHandle",0,180);
  421. Db::commit();
  422. } catch (Exception $exception) {
  423. Cache::store("redis")->set("JsHandle",0,180);
  424. Db::rollback();
  425. $output->writeln($exception->getMessage());
  426. }
  427. }
  428. Cache::store("redis")->set("JsHandle",0,180);
  429. Db::rollback();
  430. }
  431. }