diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index e825dbe3..46b7033c 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -77,7 +77,7 @@ class UserLogic extends BaseLogic try { $data=[ 'avatar' => $avatar, - 'real_name' =>'', + 'real_name' => $params['real_name']??"", 'nickname' => '用户'.time(), 'account' => $params['mobile'], 'password' => $password, @@ -88,7 +88,7 @@ class UserLogic extends BaseLogic $res=User::create($data); UserAddress::create([ 'uid' => $res['id'], - 'real_name' => $data['nickname'], + 'real_name' => $params['real_name']??"", 'mobile' => $params['mobile'], 'province' => $params['province'], 'city' => $params['city'], diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 024cb88a..ba689ab3 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -35,41 +35,7 @@ use Webman\RedisQueue\Redis; class StoreOrderController extends BaseAdminController { - // #[ - // ApiDoc\Title('订单列表'), - // ApiDoc\url('/store/store_order/storeOrder/lists'), - // ApiDoc\Method('GET'), - // ApiDoc\NotHeaders(), - // ApiDoc\Author('中国队长'), - // ApiDoc\Query(name: 'order_id', type: 'string', require: false, desc: '订单编号'), - // ApiDoc\Query(name: 'staff_id', type: 'int', require: false, desc: '店员id'), - // ApiDoc\Query(name: 'delivery_phone', type: 'int', require: false, desc: '配送员手机号'), - // ApiDoc\Query(name: 'shipping_type', type: 'int', require: false, desc: '订单配送方式:1配送订单,2核销订单,3收银台订单'), - // ApiDoc\Query(name: 'start_time', type: 'string', require: false, desc: '开始时间'), - // ApiDoc\Query(name: 'end_time', type: 'string', require: false, desc: '结束时间'), - // ApiDoc\Query(name: 'status', type: 'int', require: false, desc: '状态:-1待支付,0待发货,1待收货,2已完成'), - // ApiDoc\Header(ref: [Definitions::class, "token"]), - // ApiDoc\Query(ref: [Definitions::class, "page"]), - // ApiDoc\ResponseSuccess("data", type: "array", children: [ - // ['name' => 'id', 'desc' => 'ID', 'type' => 'int'], - // ['name' => 'order_id', 'desc' => '订单编号', 'type' => 'string'], - // ['name' => 'pay_price', 'desc' => '支付金额', 'type' => 'string'], - // ['name' => 'pay_time', 'desc' => '支付时间', 'type' => 'float'], - // ['name' => 'pay_type', 'desc' => '支付方式', 'type' => 'float'], - // ['name' => 'status_name', 'desc' => '状态', 'type' => 'int'], - // ['name' => 'staff_name', 'desc' => '店员', 'type' => 'int'], - // ['name' => 'nickname', 'desc' => '用户昵称', 'type' => 'string'], - // ['name' => 'avatar', 'desc' => '用户头像', 'type' => 'string'], - // ['name' => 'product', 'desc' => '商品信息', 'type' => 'array', 'children' => [ - // ['name' => 'cart_info', 'desc' => '商品信息', 'type' => 'array', 'children' => [ - // ['name' => 'name', 'desc' => '商品名称', 'type' => 'int'], - // ['name' => 'image', 'desc' => '图片', 'type' => 'string'], - // ['name' => 'cart_num', 'desc' => '购买数量', 'type' => 'string'], - // ['name' => 'price', 'desc' => '单价', 'type' => 'string'], - // ]], - // ]], - // ]), - // ] + /**订单列表 */ public function lists() { return $this->dataLists(new StoreOrderLists()); @@ -98,17 +64,9 @@ class StoreOrderController extends BaseAdminController ]); } - // #[ - // ApiDoc\Title('订单详情'), - // ApiDoc\url('/store/store_order/storeOrder/detail'), - // ApiDoc\Method('GET'), - // ApiDoc\NotHeaders(), - // ApiDoc\Author('中国队长'), - // ApiDoc\Header(ref: [Definitions::class, "token"]), - // ApiDoc\Query(name: 'id', type: 'int', require: false, desc: '订单id'), - // ApiDoc\Query(name: 'verify_code', type: 'string', require: false, desc: '核销码'), - // ApiDoc\ResponseSuccess("data", type: "array"), - // ] + /** + * 订单详情 + */ public function detail(StoreOrderLogic $orderLogic) { $params = (new StoreOrderValidate())->goCheck('detail'); @@ -116,11 +74,14 @@ class StoreOrderController extends BaseAdminController return $this->data($result); } + /** + * 订单检查 + */ public function checkOrder() { $cartId = (array)$this->request->post('cart_id', []); $params = $this->request->post(); - $params['store_id']=$this->adminInfo['store_id']; + $params['store_id'] = $this->adminInfo['store_id']; $res = StoreOrderLogic::cartIdByOrderInfo($cartId, null, null, $params); if ($res == false) { $msg = StoreOrderLogic::getError(); @@ -137,24 +98,23 @@ class StoreOrderController extends BaseAdminController { $params = (new StoreOrderValidate())->post()->goCheck('check'); $params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单 - $user= User::where('id',$params['uid'])->find(); - if(empty($user)){ + $user = User::where('id', $params['uid'])->find(); + if (empty($user)) { return $this->fail('无该用户请检查'); } $order = StoreOrderLogic::cartIdByOrderInfo($params['cart_id'], null, $user, $params); - if(!$order){ + if (!$order) { return $this->fail(StoreOrderLogic::getError()); } - if($order['order']['pay_price'] > $user['purchase_funds']){ + if ($order['order']['pay_price'] > $user['purchase_funds']) { return $this->fail('当前用户采购款不足支付'); } $res = (new StoreOrderLogic())->dealSendSms($params); - if($res){ - return $this->success('发送成功',[],1,0); - }else{ + if ($res) { + return $this->success('发送成功', [], 1, 0); + } else { return $this->fail('发送失败'); } - } @@ -175,8 +135,8 @@ class StoreOrderController extends BaseAdminController return $this->fail('购物车商品不能超过100个'); } $user = null; - if($pay_type == PayEnum::PURCHASE_FUNDS){ - $user = User::where('id',$this->request->post('uid'))->find(); + if ($pay_type == PayEnum::PURCHASE_FUNDS) { + $user = User::where('id', $this->request->post('uid'))->find(); } $params['store_id'] = $this->request->adminInfo['store_id']; //当前登录的店铺id,用于判断是否是当前店铺的订单 $order = StoreOrderLogic::createOrder($cartId, $addressId, $user, $params); @@ -184,13 +144,13 @@ class StoreOrderController extends BaseAdminController switch ($pay_type) { case PayEnum::PURCHASE_FUNDS: //采购款支付 - PayNotifyLogic::handle('purchase_funds', $order['order_id'],['uid'=>$this->request->post('uid')]); - return $this->success('采购款支付成功',['id'=>$order['id']]); + PayNotifyLogic::handle('purchase_funds', $order['order_id'], ['uid' => $this->request->post('uid')]); + return $this->success('采购款支付成功', ['id' => $order['id']]); case PayEnum::CASH_PAY: //现金支付 PayNotifyLogic::handle('cash_pay', $order['order_id']); - return $this->success('现金支付成功',['id'=>$order['id']]); + return $this->success('现金支付成功', ['id' => $order['id']]); case PayEnum::WECHAT_PAY_BARCODE: //微信条码支付 @@ -205,7 +165,7 @@ class StoreOrderController extends BaseAdminController Redis::send('send-code-pay', ['order_id' => $order['order_id']]); return $this->success('用户支付中'); } - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'],'id'=>$order['id']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]); case PayEnum::ALIPAY_BARCODE: //支付宝条码支付 $result = PaymentLogic::ali_auth_code($auth_code, $order); @@ -217,7 +177,7 @@ class StoreOrderController extends BaseAdminController } PayNotifyLogic::handle('alipay_cashier', $result['out_trade_no'], $result); $result['create_time'] = $order['create_time']; - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no'],'id'=>$order['id']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no'], 'id' => $order['id']]); default: return $this->fail('支付方式错误'); } @@ -252,7 +212,7 @@ class StoreOrderController extends BaseAdminController case PayEnum::CASH_PAY: //现金支付 PayNotifyLogic::handle('cash_pay', $order['order_id']); - return $this->success('现金支付成功',['id'=>$order['id']]); + return $this->success('现金支付成功', ['id' => $order['id']]); break; case PayEnum::WECHAT_PAY_BARCODE: //微信条码支付 @@ -266,7 +226,7 @@ class StoreOrderController extends BaseAdminController Redis::send('send-code-pay', ['order_id' => $order['order_id']]); return $this->success('用户支付中'); } - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'],'id'=>$order['id']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id'], 'id' => $order['id']]); case PayEnum::ALIPAY_BARCODE: //支付宝条码支付 $result = PaymentLogic::ali_auth_code($auth_code, $order); @@ -279,7 +239,7 @@ class StoreOrderController extends BaseAdminController PayNotifyLogic::handle('alipay_cashier', $result['out_trade_no'], $result); $result['create_time'] = $order['create_time']; - return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no'],'id'=>$order['id']]); + return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no'], 'id' => $order['id']]); default: return $this->fail('支付方式错误'); } @@ -296,8 +256,8 @@ class StoreOrderController extends BaseAdminController if (empty($count)) { return $this->fail('无该核销码请检查'); } - $params['store_id']=$this->adminInfo['store_id']; - $params['staff_id']=$this->adminId; + $params['store_id'] = $this->adminInfo['store_id']; + $params['staff_id'] = $this->adminId; $res = OrderLogic::writeOff($params); if ($res) { return $this->success('核销成功'); @@ -328,17 +288,16 @@ class StoreOrderController extends BaseAdminController $params['page_no'] = 1; $params['page_size'] = 15; } - $params['store_id'] =$this->request->adminInfo['store_id']; + $params['store_id'] = $this->request->adminInfo['store_id']; $result = $orderLogic->writeList($params); $data = [ 'lists' => $result, 'count' => count($result), 'page_no' => $params['page_no'], - 'page_size' =>$params['page_size'], + 'page_size' => $params['page_size'], ]; - return $this->success('ok',$data); - + return $this->success('ok', $data); } /** * vip充值 @@ -351,16 +310,16 @@ class StoreOrderController extends BaseAdminController return $this->fail('支付条码不能为空'); } $params = $this->request->post(); - $data=[ - 'store_id'=>$this->adminInfo['store_id'], - 'uid'=>$params['uid'], - 'staff_id'=>$this->adminId, - 'order_id'=>getNewOrderId('CZ'), - 'price'=>$params['price'], - 'recharge_type'=>'INDUSTRYMEMBERS', + $data = [ + 'store_id' => $this->adminInfo['store_id'], + 'uid' => $params['uid'], + 'staff_id' => $this->adminId, + 'order_id' => getNewOrderId('CZ'), + 'price' => $params['price'], + 'recharge_type' => 'INDUSTRYMEMBERS', ]; $order = UserRecharge::create($data); - $order['pay_price']=$order['price']; + $order['pay_price'] = $order['price']; switch ($pay_type) { case PayEnum::WECHAT_PAY_BARCODE: //微信条码支付 @@ -371,7 +330,7 @@ class StoreOrderController extends BaseAdminController if (isset($result['trade_state_desc']) && $result['trade_state_desc'] == '支付成功') { PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result); } else { - Redis::send('send-code-pay', ['order_id' => $order['order_id'],'pay_type'=>'recharge']); + Redis::send('send-code-pay', ['order_id' => $order['order_id'], 'pay_type' => 'recharge']); return $this->success('用户支付中'); } return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::WECHAT_PAY_BARCODE, 'transaction_id' => $result['transaction_id']]); @@ -384,7 +343,7 @@ class StoreOrderController extends BaseAdminController if ($result['msg'] !== 'Success') { return $this->success('用户支付中'); } - PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result,'ali'); + PayNotifyLogic::handle('recharge', $result['out_trade_no'], $result, 'ali'); $result['create_time'] = $order['create_time']; return $this->success('支付成功', ['out_trade_no' => $result['out_trade_no'], 'pay_type' => PayEnum::ALIPAY_BARCODE, 'transaction_id' => $result['trade_no']]); @@ -397,10 +356,10 @@ class StoreOrderController extends BaseAdminController public function stocking() { $uid = $this->request->post('uid'); - $res = (new StoreOrderLogic())->dealSendSms(['uid'=>$uid],1); - if($res){ - return $this->success('发送成功',[],0,1); - }else{ + $res = (new StoreOrderLogic())->dealSendSms(['uid' => $uid], 1); + if ($res) { + return $this->success('发送成功', [], 0, 1); + } else { return $this->fail('发送失败'); } } @@ -408,22 +367,23 @@ class StoreOrderController extends BaseAdminController /** * 订单打印 */ - public function print(){ - $id=$this->request->get('id'); + public function print() + { + $id = $this->request->get('id'); $find = StoreOrder::where('id', $id)->find(); if ($find) { $merchant = SystemStore::where('id', $find['store_id'])->field('name,phone')->find(); - $mer_user_info = SystemStoreStaff::where('store_id', $find['store_id'])->where('is_admin',1)->field('staff_name,phone')->find(); + $mer_user_info = SystemStoreStaff::where('store_id', $find['store_id'])->where('is_admin', 1)->field('staff_name,phone')->find(); $user = User::where('id', $find['uid'])->field('nickname,mobile')->find(); $find['system_store_name'] = $merchant['name']; $find['pay_type_name'] = PayEnum::getPaySceneDesc($find['pay_type']); $find['system_store_phone'] = $merchant['phone']; $find['staff_name'] = $mer_user_info['staff_name']; $find['staff_phone'] = $mer_user_info['phone']; - $find['nickname'] = $user['nickname']??''; - $find['user_mobile'] = $user['mobile']??''; + $find['nickname'] = $user['nickname'] ?? ''; + $find['user_mobile'] = $user['mobile'] ?? ''; $find['info'] = StoreOrderCartInfo::where('oid', $find['id'])->field('store_id,product_id,cart_num,cart_info')->select()->each(function ($item) { - $goods = StoreBranchProduct::where(['store_id'=>$item['store_id'],'product_id'=>$item['product_id']])->field('store_name,unit')->find(); + $goods = StoreBranchProduct::where(['store_id' => $item['store_id'], 'product_id' => $item['product_id']])->field('store_name,unit')->find(); $item['unit_name'] = StoreProductUnit::where('id', $goods['unit'])->value('name'); $item['store_name'] = $goods['store_name']; $item['total_price'] = $item['cart_info']['total_price']; @@ -432,7 +392,5 @@ class StoreOrderController extends BaseAdminController }); } return $this->success('获取成功', $find?->toArray()); - } - }