Merge pull request 'dev' (#54) from dev into main

Reviewed-on: #54
This commit is contained in:
mkm 2024-07-25 17:35:19 +08:00
commit 560c0d4320
10 changed files with 53 additions and 24 deletions

View File

@ -44,7 +44,7 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface,ListsS
public function lists(): array
{
$field = "id,nickname,real_name,sex,avatar,account,mobile,channel,create_time,purchase_funds,user_ship,
label_id,integral,now_money,total_recharge_amount";
label_id,integral,now_money,total_recharge_amount,vip_time";
$lists = User::where($this->searchWhere)
->with(['user_ship','user_label'])
->limit($this->limitOffset, $this->limitLength)
@ -62,6 +62,9 @@ class UserLists extends BaseAdminDataLists implements ListsExcelInterface,ListsS
if($item['vip_name']== null){
$item['vip_name'] = '普通会员';
}
if($item['vip_time']!= null){
$item['vip_time'] = date('Y-m-d H:i:s', $item['vip_time']);
}
if($item['label_name']== null){
$item['label_name'] = '无';
}

View File

@ -182,6 +182,7 @@ class StoreProductLogic extends BaseLogic
'batch' => $params['batch'],
'manufacturer_information' => $params['manufacturer_information']??'',
'swap' => $params['swap'] ?? 0,
'rose' => $params['rose'] ?? 0,
];
StoreProduct::where('id', $params['id'])->update($data);
@ -213,6 +214,7 @@ class StoreProductLogic extends BaseLogic
'top_cate_id'=>$dealCate['top_cate_id'],'two_cate_id'=>$dealCate['two_cate_id'],
'bar_code'=> $params['bar_code'],
'purchase'=> $params['purchase'],
'rose'=> $params['rose']??0,
]);
Db::commit();

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,

View File

@ -451,7 +451,9 @@ class PayNotifyLogic extends BaseLogic
//更新等级
$user->user_ship = $order['user_ship'];
if($user['vip_time']==null){
$user->vip_time = time();
}
$user->purchase_funds = bcadd($user->purchase_funds, $price, 2);
$user->total_recharge_amount = bcadd($user->total_recharge_amount, $price, 2);
$user->save();

View File

@ -69,6 +69,7 @@ class StoreStorageSend implements Consumer
'sales' => 0,
'product_type' => $find['product_type'],
'stock' => 0,
'rose' => $find['rose'],
];
$branch = StoreBranchProduct::create($product);
$arr = [

View File

@ -910,6 +910,7 @@ class WorkbenchLogic extends BaseLogic
->select()->toArray();
foreach ($list as $key => &$item) {
$find = StoreProduct::where('id', $item['product_id'])->field('store_name,image')->find();
if(!$find) continue;
$item['store_name'] = $find['store_name'];
$item['image'] = $find['image'];
if ($item['profit'] == null) $item['profit'] = 0;