| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <?php
- namespace business\controllers;
- use biz\merchant\services\MerchantService;
- use biz\order\services\OrderService;
- use biz\user\services\UserService;
- use common\components\configDict;
- use common\services\xhPayToolService;
- use Yii;
- use common\components\util;
- use common\components\stringUtil;
- class OrderController extends BaseController
- {
-
- public function actionList()
- {
- $get = Yii::$app->request->get();
- $status = isset($get['status']) ? $get['status'] : 0;
- $search = isset($get['search']) ? $get['search'] : '';
- $where = ['merchantId' => $this->merchantId, 'status' => $status];
- if (!empty($search)) {
- if (stringUtil::isMobile($search)) {
- $where['receiveMobile'] = $search;
- } else {
- $where['id'] = $search;
- }
- }
- $list = OrderService::getOrderList($where);
- $list['asset'] = $this->merchantAsset;
- util::success($list);
- }
- //订单详情 shish 2019.12.16
- public function actionDetail()
- {
- $id = Yii::$app->request->get('id');
- $detail = OrderService::getDetail($id);
- util::success($detail);
- }
-
- //订单归类 shish 2019.12.17
- public function actionClassify()
- {
- $post = Yii::$app->request->post();
- $id = isset($post['id']) ? $post['id'] : 0;
- $order = OrderService::getById($id);
- OrderService::valid($order, $this->merchantId);
- $categoryId = isset($post['categoryId']) ? $post['categoryId'] : $post['categoryId'];
- $usageId = isset($post['usageId']) ? $post['usageId'] : $post['usageId'];
-
- OrderService::classify($id, $categoryId, $usageId);
- util::ok();
- }
-
- //更新配送单 shish 2019.12.17
- public function actionUpdateSheet()
- {
- $post = Yii::$app->request->post();
- $id = isset($post['id']) ? $post['id'] : 0;
- unset($post['id']);
- $order = OrderService::getById($id);
- OrderService::valid($order, $this->merchantId);
- OrderService::updateSheet($order, $post);
- util::ok('提交成功');
- }
-
- //商家收款与发货 shish 2019.12.18
- public function actionGathering()
- {
- $post = Yii::$app->request->post();
- $price = isset($post['price']) && is_numeric($post['price']) ? $post['price'] : 0;
- $payWay = isset($post['payWay']) && is_numeric($post['payWay']) ? $post['payWay'] : 0;
- $userId = isset($post['userId']) ? $post['userId'] : 0;
- $userInfo = UserService::getById($userId);
- if (empty($userInfo) || $userInfo['merchantId'] != $this->merchantId) {
- util::fail('您选择的客户无效');
- }
- if ($price <= 0) {
- util::fail('请输入金额');
- }
- $post['prePrice'] = $price;
- $post['actPrice'] = $price;
- $post['payWay'] = $payWay;
- $post['sourceType'] = 1;
- $post['userId'] = $userId;
- $post['goodsNum'] = 1;
- $post['orderName'] = '商品';
- $shopId = MerchantService::getDefaultShopId($this->merchant);
- $post['shopId'] = $shopId;
- $order = OrderService::addOrder($post);
- $id = $order['id'];
- $orderSn = $order['orderSn'];
-
- //流水类型列表
- $capitalTypeList = configDict::getConfig('capitalType');
- $capitalType = $capitalTypeList['xhOrder']['id'];
- switch ($payWay) {
- case 0:
- xhPayToolService::weixinPay($orderSn, $price, $capitalType, 0);
- break;
- case 1:
- xhPayToolService::alipay($orderSn, $price, $capitalType, 0, []);
- break;
- case 2:
- xhPayToolService::balancePay($orderSn, $price, $capitalType, 0);
- break;
- default:
- util::fail('无效支付方式');
- }
- util::success($order);
- }
-
- }
|