From 96fcaf5021ef3ec36827ad6b3947b7e1b44dcea5 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 4 Jun 2024 15:26:45 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=92=8C=E6=94=AF?= =?UTF-8?q?=E4=BB=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/user/UserController.php | 3 ++- app/api/logic/LoginLogic.php | 18 ++++-------------- app/common/logic/PaymentLogic.php | 10 +++++----- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index 31f476a3a..7f82e9750 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -31,7 +31,8 @@ class UserController extends BaseApiController if ($result === false) { return $this->fail(UserLogic::getError()); } - return $this->success('绑定成功', [], 1, 1); + $data = UserLogic::info($this->userId); + return $this->success('绑定成功', $data, 1, 1); } diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php index f68c8b4a7..5e8650d34 100644 --- a/app/api/logic/LoginLogic.php +++ b/app/api/logic/LoginLogic.php @@ -25,7 +25,7 @@ use app\common\service\{ }; use app\common\model\user\{User, UserAuth}; use app\common\service\wechat\WeChatMnpService; -use think\facade\Db; + use Webman\Config; /** @@ -221,7 +221,7 @@ class LoginLogic extends BaseLogic */ public static function mnpLogin(array $params) { - Db::startTrans(); +// Db::startTrans(); try { //通过code获取微信 openid $response = (new WeChatMnpService())->getMnpResByCode($params['code']); @@ -229,21 +229,11 @@ class LoginLogic extends BaseLogic $userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo(); // 更新登录信息 self::updateLoginInfo($userInfo['id']); - //判断是不是员工 -// $userInfo['is_staff'] = 0; -// $userInfo['store_id'] = 0; -// if(isset($userInfo['mobile']) && $userInfo['mobile']){ -// $check = SystemStoreStaff::where('phone',$userInfo['mobile'])->find()??[]; -// if ($check){ -// $userInfo['is_staff'] = 1; -// $userInfo['store_id'] = $check['store_id']; -// } -// } - Db::commit(); +// Db::commit(); return $userInfo; } catch (\Exception $e) { - Db::rollback(); +// Db::rollback(); self::$error = $e->getMessage(); return false; } diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index 628fac197..852e8aa9e 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -34,9 +34,9 @@ class PaymentLogic extends BaseLogic public static function pay($payWay, $from, $order, $terminal, $redirectUrl) { // 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号) - $paySn = $order['number']; - if ($order['actual'] == 0) { - PayNotifyLogic::handle($from, $order['number']); + $paySn = $order['order_id']; + if ($order['pay_price'] == 0) { + PayNotifyLogic::handle($from, $order['order_id']); return ['pay_way' => PayEnum::BALANCE_PAY]; } switch ($payWay) { @@ -46,11 +46,11 @@ class PaymentLogic extends BaseLogic 'out_trade_no' => $paySn, 'description' => '商品', 'amount' => [ - 'total' => intval($order['actual'] * 100), + 'total' => intval($order['pay_price'] * 100), 'currency' => 'CNY', ], "payer" => [ - "openid" => $auth['openid'] ?? 0 + "openid" => $auth['openid'] ?? 'onoIP7c1qgjfIr2ce7GJAAmVGcL0' ], 'attach' => $from ]; From 9ba8995e4b562e565560a03196c5d64fe1d0bef1 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 4 Jun 2024 15:33:14 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/service/WechatUserService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/service/WechatUserService.php b/app/api/service/WechatUserService.php index 127179235..f993a94be 100644 --- a/app/api/service/WechatUserService.php +++ b/app/api/service/WechatUserService.php @@ -77,7 +77,7 @@ class WechatUserService $this->user = $user; if(!$user->isEmpty()){ - $this->user->supplier=Supplier::where('uid',$user['id'])->with('userAuth')->field('id,mer_name')->find(); +// $this->user->supplier=Supplier::where('uid',$user['id'])->with('userAuth')->field('id,mer_name')->find(); } // $this->user->merchat=Merchant::where('uid',$user['id'])->find(); return $this; From e2d21696cfb9f89c3071d4198d55a2ed79150d43 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 4 Jun 2024 15:54:42 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 16 ++++++++-------- app/functions.php | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 3b04aa3d2..5ab8c46dc 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -43,7 +43,7 @@ class OrderLogic extends BaseLogic static public function cartIdByOrderInfo($cartId, $addressId, $user = null, $params = []) { - $where = ['is_pay' => 0, 'is_del' => 0]; + $where = ['is_pay' => 0, 'delete_time' => null]; $cart_select = Cart::whereIn('id', $cartId)->where($where)->field('product_id as goods,cart_num')->select()->toArray(); if (empty($cart_select)) { self::setError('购物车为空'); @@ -59,10 +59,11 @@ class OrderLogic extends BaseLogic } $cart_select[$k]['total'] = bcmul($v['cart_num'], $find['price'], 2);//钱 $cart_select[$k]['price'] = $find['price']; - $cart_select[$k]['product_id'] = $find['goods']; + $cart_select[$k]['product_id'] = $v['goods']; $cart_select[$k]['old_cart_id'] = implode(',', $cartId); $cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['verify_code'] = $params['verify_code']; + $cart_select[$k]['cart_info'] = json_encode($cart_select[$k]); //理论上每笔都是拆分了 // $cart_select[$k]['name'] = $find['store_name']; // $cart_select[$k]['imgs'] = $find['image']; @@ -95,7 +96,7 @@ class OrderLogic extends BaseLogic * @return Object|bool|array */ static public function createOrder($cartId, $addressId, $user = null, $params = []) - { + {\request()->userId = 8; $verify_code = generateUniqueVerificationCode(); $params['verify_code'] = $verify_code; $orderInfo = self::cartIdByOrderInfo($cartId, $addressId, $user, $params); @@ -116,11 +117,10 @@ class OrderLogic extends BaseLogic $user = User::where('id', \request()->userId)->find(); $_order['real_name'] = $user['real_name']; $_order['mobile'] = $user['mobile']; - $_order['pay_type'] = $user['pay_type']; $_order['verify_code'] = $verify_code; if ($addressId > 0) { - $address = UserAddress::where(['address_id' => $addressId, 'uid' => Request()->userId])->find(); + $address = UserAddress::where(['id' => $addressId, 'uid' => \request()->userId])->find(); if ($address) { $_order['real_name'] = $address['real_name']; $_order['user_phone'] = $address['phone']; @@ -133,6 +133,7 @@ class OrderLogic extends BaseLogic // if($params['pay_type']==PayEnum::CASH_PAY){ // $_order['money']=$_order['total']; // } + Db::startTrans(); try { $order = StoreOrder::create($_order); @@ -142,11 +143,10 @@ class OrderLogic extends BaseLogic $goods_list[$k]['uid'] = request()->userId; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id'];//商家id - } (new StoreOrderCartInfo())->saveAll($goods_list); - $where = ['is_pay' => 0, 'is_del' => 0]; - Cart::whereIn('cart_id', $cartId)->where($where)->update(['is_pay' => 1]); + $where = ['is_pay' => 0, 'delete_time' => null]; + Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]); Db::commit(); return $order; } catch (\Exception $e) { diff --git a/app/functions.php b/app/functions.php index 04865a2b0..458648688 100644 --- a/app/functions.php +++ b/app/functions.php @@ -351,11 +351,11 @@ if (!function_exists('generateUniqueVerificationCode')) { $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', ''); // 生成一个随机数作为核销码的后缀 - $randomNumber = mt_rand(10000000, 99999999); // 假设核销码是8位数 + $randomNumber = mt_rand(100, 999); // 假设核销码是8位数 // 将前缀、毫秒时间戳和随机数连接起来 $type = rand(1, 10); // 生成一个1-10之间的随机数作为前缀 - return $type . $msectime . $randomNumber; + return $type .'-'. $msectime . $randomNumber; } } From 1171ad77381fb2fcd7d2ebea93dbd8489cbf9bf4 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 4 Jun 2024 16:08:44 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/order/OrderController.php | 5 +++-- app/api/lists/order/OrderList.php | 4 ++-- app/api/logic/order/OrderLogic.php | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/api/controller/order/OrderController.php b/app/api/controller/order/OrderController.php index 40da7fa4d..59f38090e 100644 --- a/app/api/controller/order/OrderController.php +++ b/app/api/controller/order/OrderController.php @@ -75,7 +75,8 @@ class OrderController extends BaseApiController $where[] = ['is_opurchase', '=', 0]; $res = StoreOrder::where($where)->whereDay('create_time', $date)->count(); return $this->success('ok', ['order_count' => $res]); - } + }*/ + public function order_count() { $userId = $this->request->userId; @@ -87,7 +88,7 @@ class OrderController extends BaseApiController $where['status'] = 1; $receiving = StoreOrder::where($where)->count(); return $this->success('ok', ['no_pay' => $no_pay, 'waiting' => $waiting, 'receiving' => $receiving]); - }*/ + } /** * @notes 检测零售订单 */ diff --git a/app/api/lists/order/OrderList.php b/app/api/lists/order/OrderList.php index cbefa413e..dca54586a 100644 --- a/app/api/lists/order/OrderList.php +++ b/app/api/lists/order/OrderList.php @@ -28,9 +28,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['paid','status','source'], + '=' => ['paid','status'], 'between_time' => 'create_time', - '%like%' => ['number'], + '%like%' => ['order_id'], ]; } diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 5ab8c46dc..8ca11fef0 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -62,7 +62,7 @@ class OrderLogic extends BaseLogic $cart_select[$k]['product_id'] = $v['goods']; $cart_select[$k]['old_cart_id'] = implode(',', $cartId); $cart_select[$k]['cart_num'] = $v['cart_num']; - $cart_select[$k]['verify_code'] = $params['verify_code']; + $cart_select[$k]['verify_code'] = $params['verify_code']??''; $cart_select[$k]['cart_info'] = json_encode($cart_select[$k]); //理论上每笔都是拆分了 // $cart_select[$k]['name'] = $find['store_name']; @@ -80,8 +80,8 @@ class OrderLogic extends BaseLogic 'total_num' => count($cart_select),//总数 'pay_type' => $params['pay_type'] ?? 0, 'cart_id' => implode(',', $cartId), - 'store_id' => $params['store_id'], - 'shipping_type' => $params['shipping_type']//配送方式 1=快递 ,2=门店自提 + 'store_id' => $params['store_id']??0, + 'shipping_type' => $params['shipping_type']??1//配送方式 1=快递 ,2=门店自提 // 'delivery_msg'=>' 预计48小时发货 ' ]; } catch (\Exception $e) { From 3f8bff16f2468423a36409047ec89c707fbd5700 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 4 Jun 2024 16:37:27 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=9C=B0=E5=9D=80?= =?UTF-8?q?=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/UploadController.php | 2 +- app/api/lists/user/UserAddressList.php | 4 ++-- app/api/logic/user/AddressLogic.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/api/controller/UploadController.php b/app/api/controller/UploadController.php index 77c71f68b..7da49ea2a 100644 --- a/app/api/controller/UploadController.php +++ b/app/api/controller/UploadController.php @@ -18,7 +18,7 @@ $cid = $this->request->post('cid', 0); $result = UploadService::image($cid); return $this->success('上传成功', $result); - } catch (Exception $e) { + } catch (\Exception $e) { return $this->fail($e->getMessage()); } } diff --git a/app/api/lists/user/UserAddressList.php b/app/api/lists/user/UserAddressList.php index b6bacad2c..5d4bca28d 100644 --- a/app/api/lists/user/UserAddressList.php +++ b/app/api/lists/user/UserAddressList.php @@ -41,9 +41,9 @@ class UserAddressList extends BaseAdminDataLists implements ListsSearchInterface $user_id=$this->request->userId; if(!$user_id) return []; return UserAddress::where($this->searchWhere)->where('uid',$user_id) - ->field('address_id,real_name,detail,phone,is_default') + ->field('id address_id,real_name,detail,phone,is_default') ->limit($this->limitOffset, $this->limitLength) - ->order(['address_id' => 'desc']) + ->order(['id' => 'desc']) ->select() ->toArray(); } diff --git a/app/api/logic/user/AddressLogic.php b/app/api/logic/user/AddressLogic.php index a1efca0c1..068aa6f0d 100644 --- a/app/api/logic/user/AddressLogic.php +++ b/app/api/logic/user/AddressLogic.php @@ -68,7 +68,7 @@ class AddressLogic extends BaseLogic 'detail' => $params['detail'], 'is_default' => $params['is_default'], ]; - UserAddress::where('uid', $params['uid'])->where('address_id', $params['address_id'])->update($data); + UserAddress::where('uid', $params['uid'])->where('id', $params['address_id'])->update($data); Db::commit(); return true; } catch (\Exception $e) { @@ -101,6 +101,6 @@ class AddressLogic extends BaseLogic */ public static function detail($params): array { - return UserAddress::field('address_id,real_name,phone,detail,is_default')->findOrEmpty($params['address_id'])->toArray(); + return UserAddress::field('id address_id,real_name,phone,detail,is_default')->where('id',$params['address_id'])->findOrEmpty()->toArray(); } }