MOrderGoods.Class.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591
  1. <?php
  2. /**
  3. * 订单商品详情数据模型
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/11/1
  7. * Time: 13:51
  8. */
  9. namespace JinDouYun\Model\Order;
  10. use JinDouYun\Controller\Common\Logger;
  11. use JinDouYun\Dao\Goods\DGoods;
  12. use JinDouYun\Model\GoodsManage\MGoodsBasic;
  13. use JinDouYun\Model\GoodsManage\MSku;
  14. use JinDouYun\Model\Shop\MShop;
  15. use JinDouYun\Model\Stock\MInventory;
  16. use Mall\Framework\Core\ErrorCode;
  17. use Mall\Framework\Core\ResultWrapper;
  18. use JinDouYun\Dao\Order\DOrderGoods;
  19. use Mall\Framework\Core\StatusCode;
  20. class MOrderGoods
  21. {
  22. private $objDOrderGoods;
  23. private $cutTable = 200000;
  24. private $onlineUserId;
  25. private $onlineEnterpriseId;
  26. /**
  27. * MOrderGoods constructor.
  28. * @param $onlineUserId
  29. * @param $onlineEnterpriseId
  30. * @throws \Exception
  31. */
  32. public function __construct($onlineUserId, $onlineEnterpriseId)
  33. {
  34. $this->onlineUserId = $onlineUserId;
  35. $this->onlineEnterpriseId = $onlineEnterpriseId;
  36. $this->objDOrderGoods = new DOrderGoods('default');
  37. self::orderGoodsSubTable();
  38. }
  39. /**
  40. * @param $enterpriseId
  41. * @param $userId
  42. * @return string
  43. * @throws \Exception
  44. */
  45. public function orderGoodsSubTable()
  46. {
  47. $tableName = $this->objDOrderGoods->getTableName($this->objDOrderGoods->get_Table() . '_' . $this->onlineEnterpriseId, $this->onlineUserId, $this->cutTable);
  48. $this->objDOrderGoods->setTable($tableName);
  49. }
  50. public function getTable()
  51. {
  52. $tableName = $this->objDOrderGoods->get_Table();
  53. return $tableName;
  54. }
  55. /**
  56. * 添加订单商品信息
  57. * @param $params
  58. * @return ResultWrapper
  59. * @throws \Exception
  60. */
  61. public function addOrderGoods($params)
  62. {
  63. $dbResult = $this->objDOrderGoods->insert($params);
  64. if ($dbResult === false) {
  65. return ResultWrapper::fail($this->objDOrderGoods->error(), ErrorCode::$dberror);
  66. } else {
  67. return ResultWrapper::success($dbResult);
  68. }
  69. }
  70. /**
  71. * 通过订单id,获取订单的商品详情
  72. * @param $selectParams
  73. * @return ResultWrapper
  74. * @throws \Exception
  75. */
  76. public function getOrderGoodsByOrderIds($selectParams)
  77. {
  78. $selectParams['deleteStatus'] = StatusCode::$standard;
  79. $dbResult = $this->objDOrderGoods->select($selectParams);
  80. if ($dbResult === false) {
  81. return ResultWrapper::fail($this->objDOrderGoods->error(), ErrorCode::$dberror);
  82. } else {
  83. $goodsResult = self::formatGoodsBasic($dbResult);
  84. if (!$goodsResult->isSuccess()){
  85. return ResultWrapper::fail($goodsResult->getData(),$goodsResult->getErrorCode());
  86. }
  87. $dbResult = $goodsResult->getData();
  88. return ResultWrapper::success(self::formatSku($dbResult));
  89. }
  90. }
  91. /**
  92. * Doc: (des="格式化sku")
  93. * User: XMing
  94. * Date: 2020/11/26
  95. * Time: 4:27 下午
  96. * @param array $params
  97. * @param string $materielIdKey
  98. * @param string $skuIdKey
  99. * @return ResultWrapper
  100. * @throws \Exception
  101. */
  102. public function formatSkuValue(array $params,$materielIdKey = 'goodsBasicId',$skuIdKey = 'skuId',$shopId = 0): ResultWrapper
  103. {
  104. $materielIds = [];
  105. foreach ($params as $param){
  106. $materielIds[] = $param[$materielIdKey];
  107. }
  108. $objMSku = new MSku($this->onlineUserId, $this->onlineEnterpriseId);
  109. //获取所有skuIds
  110. $modelResult = $objMSku->getSkuDataByGoodsIds($materielIds);
  111. if (!$modelResult->isSuccess()) {
  112. return ResultWrapper::fail($modelResult->getData(), $modelResult->getErrorCode());
  113. }
  114. $skuData = $modelResult->getData();
  115. unset($modelResult);
  116. $objDGoods = new DGoods();
  117. $objDGoods->setTable('qianniao_goods_'.$this->onlineEnterpriseId);
  118. foreach($params as &$value){
  119. $value['skuValue'] = '';
  120. $value['skuNum'] = '0';
  121. // 获取商品信息
  122. if($shopId != 0){
  123. $goodsDate = $objDGoods->get(['shopId'=>$shopId,'basicGoodsId'=>$value['materielId']]);
  124. if ($goodsDate === false) {
  125. return ResultWrapper::fail($objDGoods->error(), ErrorCode::$dberror);
  126. }
  127. // 负库存销售字段
  128. $value['isDistribution'] = $goodsDate['isDistribution'] ? $goodsDate['isDistribution'] : StatusCode::$delete;
  129. }
  130. //取出sku数据
  131. if(isset($skuData[$value[$materielIdKey]]) && isset($skuData[$value[$materielIdKey]][$value[$skuIdKey]])){
  132. //获取当前单位sku
  133. $selectSkuData = $skuData[$value[$materielIdKey]][$value[$skuIdKey]];
  134. $value['isNew'] = $selectSkuData['isNew'];
  135. $value['isMaster'] = $selectSkuData['isMaster'];
  136. $skuParam = [];
  137. $masterSku = [];//主单位
  138. //获取所有sku
  139. foreach($skuData[$value[$materielIdKey]] as $v){
  140. if($v['isMaster'] == StatusCode::$delete){
  141. if($selectSkuData['specType'] == 2){
  142. //有属性 比对哈希 找出同类型单位
  143. if($v['specGroupHash'] == $selectSkuData['specGroupHash']){
  144. $skuParam[] = $v;
  145. }
  146. }else{
  147. //无属性 都是同类型单位
  148. $skuParam[] = $v;
  149. }
  150. }else{
  151. $v['conversion'] = 1;
  152. $skuParam[] = $v;
  153. $masterSku = $v;
  154. }
  155. }
  156. if(!empty($skuParam)){
  157. //重新排序sku
  158. $conversions = array_column($skuParam,'conversion');
  159. if($masterSku['isNew'] == StatusCode::$standard){
  160. $order = SORT_DESC;
  161. }else{
  162. $order = SORT_ASC;
  163. }
  164. array_multisort($conversions,$order,$skuParam);
  165. //最小单位
  166. $smallSku = array_pop($skuParam);
  167. $skuParam[] = $smallSku;
  168. //主单位换算比例修改
  169. if($selectSkuData['isMaster'] == StatusCode::$standard){
  170. $selectSkuData['conversion'] = 1;
  171. }
  172. foreach($skuParam as $sku){
  173. //拼接比例
  174. if($sku['isMaster'] == StatusCode::$delete){
  175. if($masterSku['isNew'] == StatusCode::$standard) {
  176. $skuValues = '1'.$sku['unitName'].'='.floatval($sku['conversion']).$masterSku['unitName'];
  177. }else{
  178. $skuValues = '1'.$masterSku['unitName'].'='.floatval($sku['conversion']).$sku['unitName'];
  179. }
  180. $value['skuValue'] .= (empty($value['skuValue']) ? '':'/').$skuValues;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. return ResultWrapper::success($params);
  187. }
  188. /**
  189. * @param array $data
  190. * @return ResultWrapper
  191. * @throws \Exception
  192. */
  193. public function formatGoodsBasic(array $data)
  194. {
  195. if (empty($data)){
  196. return ResultWrapper::success([]);
  197. }
  198. $objMGoodsBasic = new MGoodsBasic($this->onlineUserId,$this->onlineEnterpriseId);
  199. $goodsBasicRes = $objMGoodsBasic->getBasicInfoByIds(['id'=>array_column($data,'goodsBasicId')]);
  200. if (!$goodsBasicRes->isSuccess()){
  201. return ResultWrapper::fail($goodsBasicRes->getData(),$goodsBasicRes->getErrorCode());
  202. }
  203. $goodsBasic = $goodsBasicRes->getData();
  204. $map = [];
  205. foreach ($goodsBasic as &$row){
  206. $map[$row['id']] = $row;
  207. }
  208. foreach ($data as $key => $item){
  209. $data[$key]['storage'] = '';
  210. if (!isset($map[$item['goodsBasicId']])){
  211. continue;
  212. }
  213. $extends = empty($map[$item['goodsBasicId']]['extends']) ? [] : json_decode($map[$item['goodsBasicId']]['extends'],true);
  214. $data[$key]['storage'] = isset($extends['storage']) ? $extends['storage'] : '';
  215. }
  216. $formatResult = self::formatSkuValue($data);
  217. if (!$formatResult->isSuccess()){
  218. return ResultWrapper::fail($formatResult->getData(),$formatResult->getErrorCode());
  219. }
  220. $data = $formatResult->getData();
  221. return ResultWrapper::success($data);
  222. }
  223. /**
  224. * @param $data
  225. * @return mixed
  226. * @throws \Exception
  227. */
  228. public function formatSku($data)
  229. {
  230. if (empty($data)){
  231. return $data;
  232. }
  233. $allSkuMapping = [];
  234. $objMSku = new MSku($this->onlineUserId,$this->onlineEnterpriseId);
  235. $skuResult = $objMSku->getSpecNameBySkuId(array_values(array_unique(array_column($data,'skuId'))));
  236. if ($skuResult->isSuccess()){
  237. $allSkuMapping = $skuResult->getData();
  238. }
  239. foreach ($data as $key => $val){
  240. $data[$key]['unitName'] = isset($allSkuMapping[$val['skuId']]) ? $allSkuMapping[$val['skuId']]['unitName'] : '';
  241. $data[$key]['specGroup'] = isset($allSkuMapping[$val['skuId']]) ? $allSkuMapping[$val['skuId']]['specGroup'] : [];
  242. if (empty($data[$key]['specGroup'])){
  243. $data[$key]['specType'] = StatusCode::$specType['single'];
  244. }else{
  245. $data[$key]['specType'] = StatusCode::$specType['multiple'];
  246. }
  247. }
  248. return $data;
  249. }
  250. /**
  251. * 修改订单详情
  252. * @param $updateData
  253. * @param $where
  254. * @return ResultWrapper
  255. */
  256. public function updateDetails($updateData, $where)
  257. {
  258. $dbResult = $this->objDOrderGoods->update($updateData, $where);
  259. if($dbResult === false){
  260. return ResultWrapper::fail($this->objDOrderGoods->error(), ErrorCode::$dberror);
  261. }
  262. return ResultWrapper::success($dbResult);
  263. }
  264. /**
  265. * @param $where
  266. * @param string $field
  267. * @return ResultWrapper
  268. */
  269. public function getDetails($where,$field='*')
  270. {
  271. $dbResult = $this->objDOrderGoods->select($where);
  272. if($dbResult === false){
  273. return ResultWrapper::fail($this->objDOrderGoods->error(), ErrorCode::$dberror);
  274. }
  275. return ResultWrapper::success($dbResult);
  276. }
  277. /**
  278. * Doc: (des="编辑商品")
  279. * User: XMing
  280. * Date: 2020/11/5
  281. * Time: 11:37 上午
  282. * @param array $params
  283. * @param int $orderId
  284. * @return ResultWrapper
  285. * @throws \Exception
  286. */
  287. public function edit(array $params,int $orderId,$no): ResultWrapper
  288. {
  289. $lists = $this->objDOrderGoods->select(['orderId'=>$orderId,'deleteStatus' => StatusCode::$standard]);
  290. if ($lists === false){
  291. return ResultWrapper::fail($this->objDOrderGoods->error(),ErrorCode::$dberror);
  292. }
  293. if (empty($lists)){
  294. return ResultWrapper::fail('商品数据为空',ErrorCode::$paramError);
  295. }
  296. if (!isset($params['goodsData']) || empty($params['goodsData'])){
  297. return ResultWrapper::fail('订单商品数据为空',ErrorCode::$paramError);
  298. }
  299. //构建锁定数据
  300. $lock = [];
  301. foreach ($lists as $v){
  302. $lock[] = [
  303. 'originId' => $orderId,
  304. 'shopId' => getArrayItem($v, 'shopId', 0),
  305. 'materielId' => getArrayItem($v, 'goodsBasicId', 0),
  306. 'materielCode' => getArrayItem($v, 'goodsCode', ''),
  307. 'lockingNum' => getArrayItem($v, 'buyNum', 0),
  308. 'originNo' => $no,
  309. 'source' => StatusCode::$orderType['saleOrder'],
  310. 'sourceNo' => $no,
  311. 'operatorId' => $this->onlineUserId,
  312. 'operatorName' => getArrayItem($v, 'name', ''),
  313. 'skuId' => getArrayItem($v, 'skuId', 0),
  314. 'goodsName' => getArrayItem($v, 'goodsName', ''),
  315. 'unitName' => getArrayItem($v, 'unitName', ''),
  316. 'specGroup' => getArrayItem($v, 'specGroup', null),
  317. ];
  318. }
  319. $shopId = 0;
  320. $haveIds = [];//已存在的id
  321. $map = [];
  322. foreach ($lists as $list){
  323. $haveIds[] = $list['id'];
  324. $map[$list['id']] = $list;
  325. $shopId = $list['shopId'];
  326. }
  327. $objMShop = new MShop($this->onlineEnterpriseId,$this->onlineUserId);
  328. $shopResult = $objMShop->getShopInfo($shopId);
  329. if (!$shopResult->isSuccess()){
  330. return ResultWrapper::fail($shopResult->getData(),$shopResult->getErrorCode());
  331. }
  332. $shop = $shopResult->getData();
  333. if (empty($shop)){
  334. return ResultWrapper::fail('获取店铺信息失败',ErrorCode::$paramError);
  335. }
  336. $update = [];
  337. $insert = [];
  338. $objMSku = new MSku($this->onlineUserId,$this->onlineEnterpriseId);
  339. foreach ($params['goodsData'] as $item){
  340. if($item['isEq'] ==StatusCode::$standard ){
  341. //超码商品
  342. $basicGoodsId = isset($item['basicGoodsId']) ? $item['basicGoodsId'] : $item['goodsBasicId'];
  343. $masterSkuResult = $objMSku->getMasterById($basicGoodsId);
  344. if (!$masterSkuResult->isSuccess()){
  345. return ResultWrapper::fail($masterSkuResult->getData(),$masterSkuResult->getErrorCode());
  346. }
  347. $masterSku = $masterSkuResult->getData();
  348. if (empty($masterSku)){
  349. return ResultWrapper::fail('超码商品单位获取异常',ErrorCode::$paramError);
  350. }
  351. $masterSku = $masterSkuResult->getData();
  352. //抄码商品为了支持主单位购买 不进行换算
  353. if($item['skuId'] != $masterSku['id']){
  354. //辅单位
  355. $conversion = $item['conversion'];
  356. $item['otherNum'] = $item['buyNum'];
  357. $u_1_buy = $item['buyNum'];//辅单位购买数量
  358. $item['buyNum'] = bcmul($item['buyNum'],$conversion,2);
  359. $item['salePrice'] = bcdiv($item['salePrice'],$conversion,2);
  360. $u = isset($masterSku['unitName']) ? $masterSku['unitName'] : '';//主单位名字
  361. $u_1 = $item['unitName'];//辅单位名字
  362. $uId_1 = $item['skuId'];//辅单位id
  363. $uId = $masterSku['id'];//主单位id
  364. }else{
  365. $skuData = $objMSku->getSkuData(['goodsId' => $basicGoodsId, 'deleteStatus' => StatusCode::$standard, 'isMaster' => StatusCode::$delete]);
  366. if(empty($skuData)){
  367. return ResultWrapper::fail('超码商品单位获取异常',ErrorCode::$paramError);
  368. // parent::sendOutput('超码商品辅单位获取异常',ErrorCode::$paramError);
  369. }
  370. $conversion = $skuData['conversion'];
  371. $u = isset($masterSku['unitName']) ? $masterSku['unitName'] : '';//主单位名字
  372. $u_1 = $skuData['unitName'];//辅单位名字
  373. $uId_1 = $skuData['skuId'];//辅单位id
  374. $uId = $masterSku['id'];//主单位id
  375. // $u_1_buy = bcdiv($item['buyNum'], $conversion, 0);//辅单位购买数量
  376. $u_1_buy = isset($item['otherNum']) && !empty($item['otherNum']) ? $item['otherNum'] : 0;
  377. }
  378. $extends = ['uId' => $uId, 'uId_1' => $uId_1, 'u' => $u, 'u_1' => $u_1,'u_1_buy'=> $u_1_buy,'conversion' => $conversion];
  379. $item['extends'] = json_encode($extends);
  380. }
  381. $lockInventoryData[] = [
  382. 'materielId' => $item['materielId'],
  383. 'materielCode' => $item['code'],
  384. 'lockingNum' => $item['buyNum'],
  385. 'originId' => $orderId,
  386. 'originNo' => $no,
  387. 'source' => StatusCode::$orderType['saleOrder'],
  388. 'sourceNo' => $no,
  389. 'operatorId' => $params['customerId'],
  390. 'operatorName' => $params['customerName'],
  391. 'skuId' => $item['skuId'],
  392. ];
  393. if (!isset($item['id']) || empty($item['id'])){
  394. //提交的数据中没有id 新增加的商品
  395. $item['no'] = $no;
  396. $item['orderId'] = $orderId;
  397. $insert[] = self::buildOrderGoodsData($item);
  398. continue;
  399. }
  400. if (in_array($item['id'],$haveIds)){
  401. //修改了此条商品数据
  402. $id = $item['id'];
  403. $item['no'] = $no;
  404. $item = self::buildOrderGoodsData($item);
  405. $item['id'] = $id;
  406. $update[] = $item;
  407. unset($map[$item['id']]);
  408. continue;
  409. }
  410. }
  411. $delete = [];
  412. foreach (array_values($map) as $value){
  413. $delete[] = $value['id'];
  414. }
  415. if (!empty($insert)){
  416. $result = $this->objDOrderGoods->insert($insert,true);
  417. if ($result === false){
  418. return ResultWrapper::fail($this->objDOrderGoods->error(),ErrorCode::$paramError);
  419. }
  420. }
  421. if(!empty($update)){
  422. foreach ($update as $value){
  423. $id = $value['id'];
  424. unset($value['id']);
  425. if (empty($id)){
  426. return ResultWrapper::fail('更新订单商品数据失败',ErrorCode::$paramError);
  427. }
  428. $value['updateTime'] = time();
  429. $result = $this->objDOrderGoods->update($value,$id);
  430. if ($result === false){
  431. return ResultWrapper::fail($this->objDOrderGoods->error(),ErrorCode::$paramError);
  432. }
  433. }
  434. }
  435. if (!empty($delete)){
  436. $result = $this->objDOrderGoods->update(['deleteStatus' => StatusCode::$delete,'updateTime' => time()],['id' => $delete]);
  437. if ($result === false){
  438. return ResultWrapper::fail($this->objDOrderGoods->error(),ErrorCode::$paramError);
  439. }
  440. }
  441. if (empty($lockInventoryData)){
  442. return ResultWrapper::fail('锁定数据构建失败',ErrorCode::$paramError);
  443. }
  444. //锁定库存商品数量
  445. $objMInventory = new MInventory($this->onlineEnterpriseId, $this->onlineUserId);
  446. $lockInventoryResult = $objMInventory->updateLockInventory($params['shopId'],$lockInventoryData);
  447. if (!$lockInventoryResult->isSuccess()) {
  448. //TODO(由于跨库不能支持事务所以有了这段奇怪的代码)
  449. //所以这里失败,重新锁定原来解锁的库存
  450. $lockInventoryRes = $objMInventory->updateLockInventory($params['shopId'],$lock);
  451. if (!$lockInventoryRes->isSuccess()){
  452. Logger::logs(E_USER_ERROR,'订单号:'.$no.',企业:'.$this->onlineEnterpriseId,__CLASS__,__LINE__,$lockInventoryRes->getData());
  453. }
  454. return ResultWrapper::fail($lockInventoryResult->getData(), $lockInventoryResult->getErrorCode());
  455. }
  456. return ResultWrapper::success(true);
  457. }
  458. /**
  459. * Doc: (des="构建商品数据")
  460. * User: XMing
  461. * Date: 2020/11/4
  462. * Time: 9:38 上午
  463. * @param array $params
  464. * @return array
  465. */
  466. public static function buildOrderGoodsData(array $params):array
  467. {
  468. return [
  469. "no" => isset($params['no']) ? $params['no'] : '',
  470. //char(25) NOT NULL COMMENT '订单编号',
  471. "orderId" => isset($params['orderId']) ? $params['orderId'] : 0,
  472. //int(10) NOT NULL DEFAULT '0' COMMENT '订单Id',
  473. "goodsCode" => isset($params['code']) ? $params['code'] : '',
  474. //varchar(255) NOT NULL DEFAULT '' COMMENT '商品编号',
  475. "goodsId" => isset($params['goodsId']) ? $params['goodsId'] : 0,
  476. //int(10) NOT NULL DEFAULT '0' COMMENT '商品Id',
  477. "goodsName" => isset($params['goodsName']) ? $params['goodsName'] : '',
  478. //varchar(50) NOT NULL DEFAULT '' COMMENT '商品名称',
  479. "shopId" => isset($params['shopId']) ? $params['shopId'] : 0,
  480. //int(10) NOT NULL DEFAULT '0' COMMENT '商铺Id',
  481. "shopName" => isset($params['shopName']) ? $params['shopName'] : '',
  482. //varchar(50) NOT NULL DEFAULT '' COMMENT '商铺名称',
  483. "merchantId" => isset($params['merchantId']) ? $params['merchantId'] : 0,
  484. //int(10) DEFAULT NULL COMMENT '商户id',
  485. "originPrice" => isset($params['salePrice']) ? $params['salePrice'] : 0,
  486. //decimal(12,2) DEFAULT '0.00' COMMENT '原始单价',
  487. "price" => isset($params['salePrice']) ? $params['salePrice'] : 0,
  488. //decimal(12,2) DEFAULT '0.00' COMMENT '商品单价',
  489. "buyNum" => isset($params['buyNum']) ? $params['buyNum'] : 0,
  490. "otherNum" => isset($params['otherNum']) ? $params['otherNum'] : 0,
  491. //decimal(10,4) NOT NULL DEFAULT '0.0000' COMMENT '购买数量',
  492. "preferential" => isset($params['preferential']) ? $params['preferential'] : 0,
  493. //decimal(12,2) DEFAULT '0.00' COMMENT '优惠券优惠金额',
  494. "totalMoney" => isset($params['subMoney']) ? $params['subMoney'] : 0,
  495. //decimal(12,2) DEFAULT '0.00' COMMENT '小计金额',
  496. "deliverNum" => isset($params['buyNum']) ? $params['buyNum'] : 0,
  497. //decimal(10,4) NOT NULL DEFAULT '0.0000' COMMENT '发货数量',
  498. "deleteStatus" => StatusCode::$standard,
  499. //tinyint(3) NOT NULL DEFAULT '5' COMMENT '是否删除 默认5 正常 4删除',
  500. "returnStatus" => isset($params['returnStatus']) ? $params['returnStatus'] : StatusCode::$orderReturn['notReturn'],
  501. //tinyint(3) DEFAULT '0' COMMENT '退货状态 0:未退货 1:已退货',
  502. "createTime" => time(),
  503. //int(10) NOT NULL DEFAULT '0' COMMENT '创建时间',
  504. "updateTime" => time(),
  505. //int(10) NOT NULL DEFAULT '0' COMMENT '更新时间',
  506. "preferentialActivityId" => isset($params['preferentialActivityId']) ? $params['preferentialActivityId'] : 0,
  507. //int(10) DEFAULT '0' COMMENT '店铺优惠活动id',
  508. "skuId" => isset($params['skuId']) ? $params['skuId'] : 0,
  509. //int(10) DEFAULT NULL COMMENT 'skuid',
  510. "goodsBasicId" => isset($params['materielId']) ? $params['materielId'] : 0,
  511. //int(10) DEFAULT NULL COMMENT 'goodsBasicId',
  512. "unitName" => isset($params['unitName']) ? $params['unitName'] : 0,
  513. //varchar(50) DEFAULT NULL COMMENT '单位名称',
  514. "conversion" => isset($params['conversion']) ? $params['conversion'] : 0,
  515. //decimal(10,2) DEFAULT NULL COMMENT '换算比率',
  516. "outCostPrice" => isset($params['outCostPrice']) ? $params['outCostPrice'] : 0,
  517. //decimal(10,2) DEFAULT NULL COMMENT '成本',
  518. "vipDiscount" => isset($params['vipDiscount']) ? $params['vipDiscount'] : 0,
  519. //decimal(12,2) DEFAULT '0.00' COMMENT '会员卡优惠金额',
  520. "categoryPath" => isset($params['categoryPath']) ? $params['categoryPath'] : '',
  521. //varchar(50) DEFAULT '' COMMENT '分类路径',
  522. "brandId" => isset($params['brandId']) ? $params['brandId'] : 0,
  523. //int(5) DEFAULT '0' COMMENT '品牌id',
  524. "specGroup" => isset($params['specGroup']) ? json_encode($params['specGroup']) : null,
  525. //json DEFAULT NULL COMMENT '规格明细',
  526. "goodsImages" => isset($params['goodsImages']) ? $params['goodsImages'] : '',
  527. //varchar(255) DEFAULT '' COMMENT '商品图',
  528. "categoryName" => isset($params['categoryName']) ? $params['categoryName'] : '',
  529. //varchar(50) DEFAULT '' COMMENT '分类名称',
  530. "brandName" => isset($params['brandName']) ? $params['brandName'] : '',
  531. //varchar(50) DEFAULT '' COMMENT '品牌名称',
  532. "barCode" => isset($params['barCode']) ? $params['barCode'] : '',
  533. //varchar(50) DEFAULT '' COMMENT '商品条码',
  534. "storageCode" => isset($params['storageCode']) ? $params['storageCode'] : '',
  535. //varchar(50) DEFAULT '' COMMENT '商品货架编码',
  536. "activityExt" => isset($params['activityExt']) ? json_encode($params['activityExt']) : null,
  537. //json DEFAULT NULL COMMENT '商品活动数据',
  538. "expressMoney" => isset($params['expressMoney']) ? $params['expressMoney'] : 0,
  539. //decimal(10,2) DEFAULT '0.00' COMMENT '运费',
  540. 'outNum' => 0,
  541. 'outOfNum' => isset($params['buyNum']) ? $params['buyNum'] : 0,
  542. //isEq
  543. 'isEq' => isset($params['isEq']) ? $params['isEq'] : 4,
  544. //抄吗商品
  545. 'extends' => isset($params['extends']) ? $params['extends'] : null,
  546. ];
  547. }
  548. }