CashierTrade.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 上海牛之云网络科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace addon\cashier\model\order;
  11. use addon\cardservice\model\MemberCard;
  12. use app\model\BaseModel;
  13. use app\model\goods\Goods;
  14. /**
  15. * 收银业务操作
  16. *
  17. * @author Administrator
  18. *
  19. */
  20. class CashierTrade extends BaseModel
  21. {
  22. public function toSend($item, $order_info)
  23. {
  24. $action_type = $item[ 'goods_class' ];//操作类型
  25. if (in_array($action_type, [ 1, 4, 5, 6 ])) {
  26. switch ( $action_type ) {
  27. case '5'://卡项
  28. $result = $this->toCard($item, $order_info);
  29. break;
  30. case '1'://实物
  31. $result = $this->toGoods($item, $order_info);
  32. break;
  33. case '6'://称重商品
  34. $result = $this->toGoods($item, $order_info);
  35. break;
  36. case '4'://服务
  37. $result = $this->toService($item, $order_info);
  38. break;
  39. }
  40. if (!empty($result)) {
  41. if ($result[ 'code' ] < 0) {
  42. return $result;
  43. }
  44. }
  45. //累加销量
  46. $goods_model = new Goods();
  47. $goods_model->incGoodsSaleNum($item[ 'sku_id' ], $item[ 'num' ], $item[ 'store_id' ] ?? 0);
  48. }
  49. $order_goods_data = array (
  50. //配送状态
  51. 'delivery_status' => 2,
  52. 'delivery_status_name' => '已收货',
  53. );
  54. model('order_goods')->update($order_goods_data, [ [ 'order_goods_id', '=', $item[ 'order_goods_id' ] ] ]);
  55. return $this->success();
  56. }
  57. /**
  58. * 生成卡项
  59. * @param $params
  60. * @return array
  61. */
  62. public function toCard($params, $order_info)
  63. {
  64. $member_card_model = new MemberCard();
  65. $num = $params[ 'num' ];
  66. $i = 0;
  67. while ($i < $num) {
  68. $result = $member_card_model->create($params);
  69. if ($result[ 'code' ] < 0) {
  70. return $result;
  71. }
  72. $i++;
  73. }
  74. return $this->success();
  75. }
  76. /**
  77. * 生成预约服务
  78. * @param $order_info
  79. * @return array
  80. */
  81. public function toService($params, $order_info)
  82. {
  83. $store_id = $order_info[ 'store_id' ];
  84. return $this->success();
  85. }
  86. /**
  87. * 实物处理
  88. * @param $params
  89. * @param $order_info
  90. * @return array
  91. */
  92. public function toGoods($params, $order_info)
  93. {
  94. // $store_id = $order_info['store_id'];
  95. //
  96. // //扣除库存
  97. // $order_stock_model = new OrderStock();
  98. // $stock_params = array(
  99. // 'store_id' => $store_id,
  100. // 'sku_id' => $params['sku_id'],
  101. // 'goods_id' => $params['goods_id'],
  102. // 'stock' => $params['num'],
  103. // 'goods_class' => $params['goods_class'],
  104. // 'site_id' => $order_info['site_id'],
  105. // 'user_info' => [
  106. // 'uid' => $order_info['cashier_operator_id'],
  107. // 'username' => $order_info['cashier_operator_name'],
  108. // ]
  109. // );
  110. // $result = $order_stock_model->decOrderStock($stock_params);
  111. // return $result;
  112. }
  113. }