123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- <?php
- /**
- * Niushop商城系统 - 团队十年电商经验汇集巨献!
- * =========================================================
- * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
- * ----------------------------------------------
- * 官方网址: https://www.niushop.com.cn
- * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
- * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
- * =========================================================
- */
- namespace app\model\order;
- use app\model\goods\GoodsStock;
- /**
- * 外卖订单
- *
- * @author Administrator
- *
- */
- class LocalOrder extends OrderCommon
- {
- /*****************************************************************************************订单基础状态(其他使用)********************************/
- // 订单待付款
- const ORDER_CREATE = 0;
-
- // 订单已支付(待发货)
- const ORDER_PAY = 1;
-
- // 订单备货中
- const ORDER_PENDING_DELIVERY = 2;
-
- // 订单已发货(配货)
- const ORDER_DELIVERY = 3;
-
- // 订单已收货
- const ORDER_TAKE_DELIVERY = 4;
-
- // 订单已结算完成
- const ORDER_COMPLETE = 10;
-
- // 订单已关闭
- const ORDER_CLOSE = -1;
-
- /***********************************************************************************订单项 配送状态**************************************************/
- // 待发货
- const DELIVERY_WAIT = 0;
-
- // 已发货
- const DELIVERY_DOING = 1;
-
- // 已收货
- const DELIVERY_FINISH = 2;
-
-
- /**
- * 订单类型
- *
- * @var int
- */
- public $order_type = 3;
-
-
- /**
- * 基础订单状态(不同类型的订单可以不使用这些状态,但是不能冲突)
- * @var unknown
- */
- public $order_status = [
- self::ORDER_CREATE => [
- 'status' => self::ORDER_CREATE,
- 'name' => '待支付',
- 'is_allow_refund' => 0,
- 'action' => [
- [
- 'action' => 'orderClose',
- 'title' => '关闭订单',
- 'color' => ''
- ],
- [
- 'action' => 'orderAddressUpdate',
- 'title' => '修改地址',
- 'color' => ''
- ],
- [
- 'action' => 'orderAdjustMoney',
- 'title' => '调整价格',
- 'color' => ''
- ],
- ],
- 'member_action' => [
- [
- 'action' => 'orderClose',
- 'title' => '关闭订单',
- 'color' => ''
- ],
- [
- 'action' => 'orderPay',
- 'title' => '支付',
- 'color' => ''
- ],
- ],
- 'color' => ''
- ],
- self::ORDER_PAY => [
- 'status' => self::ORDER_PAY,
- 'name' => '待发货',
- 'is_allow_refund' => 0,
- 'action' => [
- [
- 'action' => 'orderLocalDelivery',
- 'title' => '发货',
- 'color' => ''
- ],
- ],
- 'member_action' => [
-
- ],
- 'color' => ''
- ],
- self::ORDER_DELIVERY => [
- 'status' => self::ORDER_DELIVERY,
- 'name' => '已发货',
- 'is_allow_refund' => 1,
- 'action' => [
- ],
- 'member_action' => [
- [
- 'action' => 'memberTakeDelivery',
- 'title' => '确认收货',
- 'color' => ''
- ],
- ],
- 'color' => ''
- ],
- self::ORDER_TAKE_DELIVERY => [
- 'status' => self::ORDER_TAKE_DELIVERY,
- 'name' => '已收货',
- 'is_allow_refund' => 1,
- 'action' => [
- ],
- 'member_action' => [
- ],
- 'color' => ''
- ],
- self::ORDER_COMPLETE => [
- 'status' => self::ORDER_COMPLETE,
- 'name' => '已完成',
- 'is_allow_refund' => 1,
- 'action' => [
- ],
- 'member_action' => [
-
- ],
- 'color' => ''
- ],
- self::ORDER_CLOSE => [
- 'status' => self::ORDER_CLOSE,
- 'name' => '已关闭',
- 'is_allow_refund' => 0,
- 'action' => [
-
- ],
- 'member_action' => [
-
- ],
- 'color' => ''
- ],
- ];
-
- /**
- * 配送状态
- */
- public $delivery_status = [
- self::DELIVERY_WAIT => [
- 'status' => self::DELIVERY_WAIT,
- 'name' => '待发货',
- 'color' => ''
- ],
- self::DELIVERY_DOING => [
- 'status' => self::DELIVERY_DOING,
- 'name' => '已发货',
- 'color' => ''
- ],
- self::DELIVERY_FINISH => [
- 'status' => self::DELIVERY_FINISH,
- 'name' => '已收货',
- 'color' => ''
- ]
- ];
-
- /**
- * 订单支付
- * @param unknown $order_info
- */
- public function orderPay($order_info, $pay_type)
- {
- if ($order_info['order_status'] != 0) {
- return $this->error();
- }
- $condition = array(
- [ "order_id", "=", $order_info["order_id"] ],
- [ "order_status", "=", self::ORDER_CREATE ],
- );
- $pay_type_list = $this->getPayType();
- $data = array(
- "order_status" => self::ORDER_PAY,
- "order_status_name" => $this->order_status[ self::ORDER_PAY ]["name"],
- "pay_status" => 1,
- "order_status_action" => json_encode($this->order_status[ self::ORDER_PAY ], JSON_UNESCAPED_UNICODE),
- "pay_time" => time(),
- "is_enable_refund" => 1,
- "pay_type" => $pay_type,
- "pay_type_name" => $pay_type_list[ $pay_type ]
- );
- $result = model("order")->update($data, $condition);
- return $this->success($result);
- }
-
- /**
- * 订单发货
- *
- * @param array $condition
- */
- public function orderDelivery($order_id)
- {
- $res = model('order_goods')->update([ 'delivery_status' => 1, 'delivery_status_name' => "已发货" ], [ 'order_id' => $order_id ]);
-
- $order_data = array(
- 'order_status' => self::ORDER_DELIVERY,
- 'order_status_name' => $this->order_status[ self::ORDER_DELIVERY ]["name"],
- 'delivery_status' => self::DELIVERY_FINISH,
- 'delivery_status_name' => $this->delivery_status[ self::DELIVERY_FINISH ]["name"],
- 'order_status_action' => json_encode($this->order_status[ self::ORDER_DELIVERY ], JSON_UNESCAPED_UNICODE),
- );
- $res = model('order')->update($order_data, [ [ 'order_id', "=", $order_id ] ]);
-
- return $this->success($res);
-
- }
-
- /**
- * 订单收货
- *
- * @param int $order_id
- */
- public function orderTakeDelivery($order_id)
- {
- return $this->success();
- }
-
- /**
- * 退款完成操作
- * @param $order_info
- */
- public function refund($order_goods_info)
- {
- //是否入库
- if ($order_goods_info["is_refund_stock"] == 1) {
- $goods_stock_model = new GoodsStock();
- $item_param = array(
- "sku_id" => $order_goods_info["sku_id"],
- "num" => $order_goods_info["num"],
- );
- //返还库存
- $goods_stock_model->incStock($item_param);
- }
- }
-
- /**
- * 订单详情
- * @param $order_info
- */
- public function orderDetail($order_info)
- {
- return [];
- }
- }
|