Merge pull request 'rose' (#49) from rose into dev

Reviewed-on: #49
This commit is contained in:
mkm 2024-07-25 09:35:29 +08:00
commit d50382f17e
5 changed files with 42 additions and 22 deletions

View File

@ -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());

View File

@ -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')??0;
}
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']) {

View File

@ -35,8 +35,16 @@ class AddressLogic extends BaseLogic
'uid' => $params['uid'],
'real_name' => $params['real_name'],
'phone' => $params['phone'],
'detail' => $params['detail'],
'province'=> $params['province'],
'city' => $params['city'],
'area' => $params['area'],
'street' => $params['street'],
'village' => $params['village'],
'brigade' => $params['brigade'],
'detail' => '',
'is_default' => $params['is_default'],
'create_time' => time(),
'update_time' => time(),
]);
Db::commit();
return $id;

View File

@ -21,7 +21,11 @@ class UserAddressValidate extends BaseValidate
protected $rule = [
'real_name' => 'require',
'phone' => 'require',
'detail' => 'require',
'city' => 'require',
'area' => 'require',
'street' => 'require',
'village' => 'require',
'brigade' => 'require',
'address_id' => 'require',
"is_default"=>"require|in:0,1"
@ -38,7 +42,12 @@ class UserAddressValidate extends BaseValidate
'phone' => '收货人电话',
'detail' => '收货人详细地址',
'address_id' => '地址id',
"is_default"=>"默认地址"
"is_default"=>"默认地址",
'city'=>'城市',
'area'=>'区',
'street'=>'街道',
'village'=>'村',
'brigade'=>'队'
];
@ -51,7 +60,7 @@ class UserAddressValidate extends BaseValidate
*/
public function sceneAdd()
{
return $this->only(['real_name','phone','detail']);
return $this->only(['real_name','phone','city','area','street','village','brigade']);
}
@ -63,7 +72,7 @@ class UserAddressValidate extends BaseValidate
*/
public function sceneEdit()
{
return $this->only(['real_name','phone','id']);
return $this->only(['real_name','phone','id','city','area','street','village','brigade']);
}

View File

@ -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,