From 9a9c836f34911ffe7a9d3eae4d5db497b31959ac Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 5 Jun 2024 18:39:11 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=AD=89=E7=BA=A7=E5=92=8C=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 29 ++++++++++++++++++++++++++++- app/common/logic/PaymentLogic.php | 2 +- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 72017f7b9..e7ecffde9 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -7,6 +7,7 @@ use app\common\{logic\BaseLogic, model\system_store\SystemStore, model\user\User, model\user\UserRecharge, + model\user\UserShip, service\wechat\WeChatMnpService}; /** @@ -60,12 +61,20 @@ class UserLogic extends BaseLogic public static function info($uid) { $data = User::where('id',$uid) - ->field('avatar,real_name,nickname,account,mobile,sex,login_ip,user_money') + ->field('avatar,real_name,nickname,account,mobile,sex,login_ip,user_money,total_recharge_amount,user_ship') ->find(); //判断是不是员工 if($data){ $data = $data->toArray(); + $all =UserShip::field('id,title,limit')->select()->toArray(); + $new = self::getNextArrayByID($all,$data['user_ship']); + $data['next_level'] = ''; + $data['next_limit'] = 0; + if($new){ + $data['next_level'] = $new['title']; + $data['next_limit'] = $new['limit'] - $data['total_recharge_amount']; + } $data['is_staff'] = 0; $data['store_id'] = 0; if(isset($data['mobile']) && $data['mobile']){ @@ -91,4 +100,22 @@ class UserLogic extends BaseLogic } + public static function getNextArrayByID($arr, $id) { + // 遍历数组 + foreach ($arr as $key => $value) { + // 检查当前数组的id是否与传入的id匹配 + if ($value['id'] == $id) { + // 如果当前数组不是最后一个,则返回下一个数组 + if ($key + 1 < count($arr)) { + return $arr[$key + 1]; + } + // 如果当前数组是最后一个,则返回null或空数组 + return null; + } + } + // 如果没有找到匹配的id,则返回null或空数组 + return null; + } + + } \ No newline at end of file diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index 124ece936..0bcec9da2 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -34,7 +34,7 @@ class PaymentLogic extends BaseLogic { // 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号) $paySn = $order['order_id']; - if ($order['pay_price'] == 0) { + if ($order['pay_price'] === 0) { PayNotifyLogic::handle($from, $order['order_id']); return ['pay_way' => PayEnum::BALANCE_PAY]; } From 750f54b45328e5203ef103f458947a2bbbcfa82e Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 5 Jun 2024 18:44:18 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=AD=89=E7=BA=A7=E5=92=8C=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=94=AF=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/PaymentLogic.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index 0bcec9da2..7f8ac0595 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -39,6 +39,9 @@ class PaymentLogic extends BaseLogic return ['pay_way' => PayEnum::BALANCE_PAY]; } try { + if(isset($order['price'])){ + $order['pay_price'] = $order['price']; + } switch ($payWay) { case PayEnum::WECHAT_PAY: $auth = UserAuth::where(['user_id' => $order['uid'], 'terminal' => $terminal])->findOrEmpty(); From cfed701649335c63996cdd8682680f988724a2ee Mon Sep 17 00:00:00 2001 From: liuchaofu <1873441552@qq.com> Date: Wed, 5 Jun 2024 22:47:49 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=A0=B8=E9=94=80=E7=A0=81=E6=9F=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 22 ++++++++++++++++++-- app/api/logic/order/OrderLogic.php | 17 +++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 0f455e2c4..76cd245ff 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -28,6 +28,25 @@ class OrderController extends BaseApiController return $this->dataLists(new OrderList()); } + #[ + ApiDoc\Title('核销码查数据'), + ApiDoc\url('/api/order/order/write_code'), + ApiDoc\Method('POST'), + ApiDoc\Param(name: "code", type: "string", require: false, desc: "核销码"), + ApiDoc\NotHeaders(), + ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"), + ApiDoc\ResponseSuccess("data", type: "array"), + ] + public function write_code() + { + $code = $this->request->post('code'); + if(empty($code)){ + return $this->fail('缺失参数'); + } + $res = OrderLogic::getOne($code); + return $this->success('ok',$res); + } + #[ ApiDoc\Title('核销订单列表'), ApiDoc\url('/api/order/order/write_list'), @@ -402,8 +421,7 @@ class OrderController extends BaseApiController public function writeoff_order() { $params = (new OrderValidate())->post()->goCheck('check'); - $userId = $this->request->userId; - $res = OrderLogic::writeOff($params,$userId); + $res = OrderLogic::writeOff($params); if ($res) { return $this->success('核销成功'); } diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index f5a1b73a0..83c87a75a 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -436,7 +436,6 @@ class OrderLogic extends BaseLogic /** * @param $params - * @param $uid * @return bool * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException @@ -444,11 +443,10 @@ class OrderLogic extends BaseLogic * @author: codeliu * @Time: 2024/6/3 22:42 */ - public static function writeOff($params, $uid): bool + public static function writeOff($params): bool { $data = StoreOrder::with('store')->where([ - 'verify_code' => $params['verify_code'], - 'uid' => $uid + 'verify_code' => $params['verify_code'] ])->find(); if (empty($data)) { return false; @@ -520,6 +518,17 @@ class OrderLogic extends BaseLogic } + public static function getOne($code) + { + return StoreOrder::with(['store'])->where('verify_code',$code) + ->select()->each(function ($item) { + $item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with('goodsName')->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time')->limit(3)->select(); + $item['goods_count']=count(explode(',',$item['cart_id'])); + return $item; //返回处理后的数据。 + }) + ->toArray(); + + } public static function write_list($info,$status,$params) { From 07103bbf651f23bc08ed52f960d4234376d41660 Mon Sep 17 00:00:00 2001 From: liuchaofu <1873441552@qq.com> Date: Wed, 5 Jun 2024 23:00:13 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=9A=E5=91=98=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/UserLogic.php | 3 +-- app/common/model/user/User.php | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index e7ecffde9..1adee2af9 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -60,10 +60,9 @@ class UserLogic extends BaseLogic public static function info($uid) { - $data = User::where('id',$uid) + $data = User::with(['userShip'])->where('id',$uid) ->field('avatar,real_name,nickname,account,mobile,sex,login_ip,user_money,total_recharge_amount,user_ship') ->find(); - //判断是不是员工 if($data){ $data = $data->toArray(); diff --git a/app/common/model/user/User.php b/app/common/model/user/User.php index 5ba4141c1..6917e0c4e 100644 --- a/app/common/model/user/User.php +++ b/app/common/model/user/User.php @@ -21,6 +21,13 @@ class User extends BaseModel protected $deleteTime = 'delete_time'; + public function userShip() + { + return $this->hasOne(UserShip::class,'id','user_ship') +// return $this->hasOne(UserShip::class,'user_ship','id') + ->bind(['vip_name'=>'title','discount','limit']); + } + /** * @notes 关联用户授权模型 * @return \think\model\relation\HasOne From 73dece72374c308e315ac78a5940000eae89e51e Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 6 Jun 2024 09:24:31 +0800 Subject: [PATCH 5/5] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4json=E5=AD=97?= =?UTF-8?q?=E7=AC=A6=E4=B8=B2=E8=BD=AC=E6=8D=A2=E4=B8=BA=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lists/store_order_cart_info/StoreOrderCartInfoLists.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php index 71442bf21..f6f8d4d15 100644 --- a/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php +++ b/app/admin/lists/store_order_cart_info/StoreOrderCartInfoLists.php @@ -47,7 +47,6 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI return StoreOrderCartInfo::where($this->searchWhere) ->field('cart_info,product_id')->limit($this->limitOffset, $this->limitLength) ->select()->each(function ($item) { - $item['cart_info'] = json_decode($item['cart_info'], true); //将json字符串转换为数组,方便使用其中的数据。 $find=StoreBranchProduct::where('id',$item['product_id'])->field('image,store_name')->find(); if($find){ $item['image']=$find['image'];//商品图片