diff --git a/app/api/logic/LoginLogic.php b/app/api/logic/LoginLogic.php index c4d715a3..f5982542 100644 --- a/app/api/logic/LoginLogic.php +++ b/app/api/logic/LoginLogic.php @@ -112,6 +112,7 @@ class LoginLogic extends BaseLogic 'store_id' => SystemStoreStaff::where('phone',$userInfo['mobile'])->value('store_id')??null, // 'sn' => $userInfo['sn'], 'token' => $userInfo['token'], + 'real_name' => $userInfo['real_name'], ]; } catch (\Exception $e) { self::setError($e->getMessage()); diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 91258b10..1c794315 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -52,7 +52,6 @@ class OrderLogic extends BaseLogic public static $total_price; public static $pay_price; public static $cost; - public static $profit; public static $store_price; //门店零售价 public static $activity_price; public static $deduction_price; @@ -71,11 +70,10 @@ class OrderLogic extends BaseLogic self::setError('购物车为空'); return false; } - // try { + try { self::$total_price = 0; self::$pay_price = 0; self::$cost = 0; //成本由采购价替代原成本为门店零售价 - self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 self::$store_price = 0; //商户价 self::$deduction_price = 0; @@ -113,8 +111,8 @@ class OrderLogic extends BaseLogic } else { $price = $find['price']; } - if($off_activity==0 && $find['top_cate_id']==15189 && $user&&$user['user_ship']==5){ - $price=$find['cost']; + if ($off_activity == 0 && $find['top_cate_id'] == 15189 && $user && $user['user_ship'] == 5) { + $price = $find['cost']; } $cart_select[$k]['price'] = $price; $cart_select[$k]['cost'] = $find['cost']; @@ -192,7 +190,7 @@ class OrderLogic extends BaseLogic 'order_id' => $params['order_id'] ?? getNewOrderId('PF'), 'total_price' => self::$total_price, //总价 'cost' => self::$cost, //成本价1- - 'pay_price' => $pay_price, //后期可能有降价抵扣 + 'pay_price' => $pay_price, //支付价 'vip_price' => 0, 'total_num' => count($cart_select), //总数 'pay_type' => $params['pay_type'] ?? 0, @@ -202,11 +200,12 @@ class OrderLogic extends BaseLogic 'shipping_type' => $params['shipping_type'] ?? 2, //配送方式 1=快递 ,2=门店自提 'activity' => '减免', 'activity_price' => self::$activity_price, - 'activities' => self::$activity_price > 0 ? 1 : 0, - 'deduction_price' => self::$deduction_price, - 'frozen_money' => self::$frozen_money, //返还金额(活动关闭得时候有) + 'activities' => $off_activity, + 'deduction_price' => self::$deduction_price, //抵扣金额 + 'frozen_money' => 0, //self::$frozen_money, //返还金额(活动关闭得时候有) 'source' => 0, 'is_storage' => $params['is_storage'] ?? 0, + 'address_id' => 0, ]; $order['default_delivery'] = 0; if ($params['store_id']) { @@ -230,6 +229,7 @@ class OrderLogic extends BaseLogic $store_id = getenv('STORE_ID') ?? 1; $store['near_store'] = SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find() ?? []; } + // $order['address_id'] = UserAddress::where('uid', $user['id'])->where('is_default', 1)->value('id'); } if (empty($store_check)) { if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { @@ -249,10 +249,10 @@ class OrderLogic extends BaseLogic } } } - // } catch (\Exception $e) { - // self::setError($e->getMessage()); - // return false; - // } + } catch (\Exception $e) { + self::setError($e->getMessage()); + return false; + } return ['order' => $order, 'cart_list' => $cart_select, 'shopInfo' => $store['near_store']]; } @@ -284,7 +284,8 @@ class OrderLogic extends BaseLogic $_order['pay_type'] = $orderInfo['order']['pay_type']; $_order['verify_code'] = $verify_code; $_order['reservation_time'] = null; - $_order['reservation'] = 0;$params['reservation'] ?? 0; //是否需要预约 + $_order['reservation'] = 0; + $params['reservation'] ?? 0; //是否需要预约 // if (isset($params['reservation_time']) && $params['reservation_time']) { // $_order['reservation_time'] = $params['reservation_time']; // $_order['reservation'] = YesNoEnum::YES; @@ -300,7 +301,7 @@ class OrderLogic extends BaseLogic if ($params['shipping_type'] == 2) { $_order['status'] = 1; } - if ($_order['pay_type']==PayEnum::BALANCE_PAY && $user!=null&&$user['now_money'] < $_order['pay_price']) { + if ($_order['pay_type'] == PayEnum::BALANCE_PAY && $user != null && $user['now_money'] < $_order['pay_price']) { throw new \Exception('余额不足'); } //生成核销码 @@ -506,10 +507,10 @@ class OrderLogic extends BaseLogic if ($find['verify_img']) { $find['verify_img'] = $url . $find['verify_img']; } - if($find['is_writeoff']==0){ + if ($find['is_writeoff'] == 0) { $generator = new BarcodeGeneratorPNG(); $tmpFilename = $generator->getBarcode($find['verify_code'], $generator::TYPE_CODE_128); - $find['verify_base64'] = 'data:image/png;base64,'.base64_encode($tmpFilename); + $find['verify_base64'] = 'data:image/png;base64,' . base64_encode($tmpFilename); } //处理返回最近的店铺 if ($param['lat'] && $param['long']) { diff --git a/app/common/cache/UserTokenCache.php b/app/common/cache/UserTokenCache.php index db1ae76e..af6509a4 100644 --- a/app/common/cache/UserTokenCache.php +++ b/app/common/cache/UserTokenCache.php @@ -77,6 +77,7 @@ class UserTokenCache extends BaseCache $userInfo = [ 'user_id' => $user->id, 'nickname' => $user->nickname, + 'real_name' => $user->real_name, 'token' => $token, 'mobile' => $user->mobile, 'avatar' => $user->avatar,