diff --git a/app/admin/controller/IndexController.php b/app/admin/controller/IndexController.php new file mode 100644 index 00000000..0a45e2c1 --- /dev/null +++ b/app/admin/controller/IndexController.php @@ -0,0 +1,27 @@ +request->get('order_no'); + $order = [ + 'out_trade_no' => $order_no, + ]; + $app = new PayService(0); + + try { + $res = $app->wechat->query($order); + return $this->success('查询成功', $res->toArray()); + } catch (\Exception $e) { + return $this->fail($e->extra['message']); + } + } +} \ No newline at end of file diff --git a/app/admin/controller/user/UserController.php b/app/admin/controller/user/UserController.php index 2f83ae7b..3beea43f 100644 --- a/app/admin/controller/user/UserController.php +++ b/app/admin/controller/user/UserController.php @@ -81,5 +81,21 @@ class UserController extends BaseAdminController return $this->success('ok', $res); } + + //用户领取列表 + public function userGiftList() + { + $uid = (new UserValidate())->goCheck('detail'); + $page_no = (int)$this->request->get('page_no', 1); + $page_size = (int)$this->request->get('page_size', 15); + $params = $this->request->get(); + $params['page_no'] = $page_no > 0 ? $page_no : 1; + $params['page_size'] = $page_size > 0 ? $page_size : 15; + $uid = $uid['id']; + $res = UserLogic::giftList($uid,$params); + $res['page_no'] = $params['page_no']; + $res['page_size'] = $params['page_size']; + return $this->success('ok', $res); + } } \ No newline at end of file diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 1220fab2..38ee89a6 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -210,7 +210,8 @@ class StoreProductLogic extends BaseLogic 'batch'=>$params['batch'],'store_name'=>$params['store_name'], 'manufacturer_information' => $params['manufacturer_information']??'', 'store_info' => $params['store_info']??'','cate_id'=>$params['cate_id'], - 'top_cate_id'=>$dealCate['top_cate_id'],'two_cate_id'=>$dealCate['two_cate_id'] + 'top_cate_id'=>$dealCate['top_cate_id'],'two_cate_id'=>$dealCate['two_cate_id'], + 'bar_code'=> $params['bar_code'] ]); Db::commit(); diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index d911d34f..8b2f6729 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -20,6 +20,7 @@ use app\common\logic\BaseLogic; use app\common\model\finance\CapitalFlow; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; +use app\common\model\store_product_gift\StoreProductGift; use app\common\model\user\User; use app\common\model\user\UserAddress; use app\common\model\user\UserRecharge; @@ -77,6 +78,34 @@ class UserLogic extends BaseLogic public static function StoreAdd(array $params) { + $user_ship=$params['user_ship']??0; + if($user_ship==2){ + if(!isset($params['village'])){ + self::setError('请设置村参数'); + return false; + } + $arr=User::where('user_ship',$user_ship)->column('id'); + if($arr){ + $find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->find(); + if($find){ + self::setError('该区域已有村长请重新选择'); + return false; + } + } + }elseif($user_ship==3){ + if(!isset($params['brigade'])){ + self::setError('请设置队参数'); + return false; + } + $arr=User::where('user_ship',$user_ship)->column('id'); + if($arr){ + $find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->where('brigade',$params['brigade'])->find(); + if($find){ + self::setError('该区域已有队长请重新选择'); + return false; + } + } + } $passwordSalt = Config::get('project.unique_identification'); $password = create_password(123456, $passwordSalt); $defaultAvatar = config('project.default_image.admin_avatar'); @@ -102,6 +131,7 @@ class UserLogic extends BaseLogic 'create_uid' => $params['create_uid']??0, 'store_id' => $params['store_id']??0, 'staff_id' => $params['staff_id']??0, + 'user_ship' => $data['user_ship']??0, ]); UserAddress::create([ 'uid' => $res['id'], @@ -200,7 +230,7 @@ class UserLogic extends BaseLogic switch ($params['type']){ case 1: //采购款明细 - $categories = ['user_balance_recharge', 'user_order_purchase_pay','system_purchase_add']; + $categories = ['user_balance_recharge', 'user_order_purchase_pay','system_purchase_add','user_balance_recharge_refund']; $query = CapitalFlow::where('uid', $params['id']) ->whereIn('category', $categories); $count = $query->count(); @@ -260,4 +290,18 @@ class UserLogic extends BaseLogic } + + public static function giftList($uid,$params) + { + $query = StoreProductGift::with(['store','user','goodsName'])->where('uid',$uid); + $count = $query->count(); + $list = $query->page($params['page_no'],$params['page_size']) + ->order('id','desc') + ->select()->toArray(); + return [ + 'lists' => $list, + 'count' => $count + ]; + + } } diff --git a/app/admin/logic/user_ship/UserShipLogic.php b/app/admin/logic/user_ship/UserShipLogic.php index 0166b1a8..cf804069 100644 --- a/app/admin/logic/user_ship/UserShipLogic.php +++ b/app/admin/logic/user_ship/UserShipLogic.php @@ -5,6 +5,8 @@ namespace app\admin\logic\user_ship; use app\common\model\user_ship\UserShip; use app\common\logic\BaseLogic; +use app\common\model\user\User; +use app\common\model\user\UserAddress; use think\facade\Db; @@ -95,4 +97,47 @@ class UserShipLogic extends BaseLogic { return UserShip::findOrEmpty($params['id'])->toArray(); } + + /** + * 判断是否有村长或者对长 + * @param $params array 参数数组 + */ + public static function user_ship($params){ + $user_ship=$params['user_ship']??0; + if($user_ship==2){ + if(!isset($params['village'])){ + self::setError('请设置村参数'); + return false; + } + $arr=User::where('user_ship',$user_ship)->column('id'); + if($arr){ + $find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->find(); + if($find){ + if($params['uid']==$find['uid']){ + return true; + } + self::setError('该区域已有村长请重新选择'); + return false; + } + } + }elseif($user_ship==3){ + if(!isset($params['brigade'])){ + self::setError('请设置队参数'); + return false; + } + $arr=User::where('user_ship',$user_ship)->column('id'); + if($arr){ + $find=UserAddress::where('uid','in',$arr)->where('village',$params['village'])->where('brigade',$params['brigade'])->find(); + if($find){ + if($params['uid']==$find['uid']){ + return true; + } + self::setError('该区域已有队长请重新选择'); + return false; + } + } + } + return true; + } + } \ No newline at end of file diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index df0eb102..2a0ea7cf 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -38,16 +38,18 @@ class PayController extends BaseApiController $app->wechat->success(); break; case 'wechat_common': - default: PayNotifyLogic::handle('wechat_common', $ciphertext['out_trade_no'], $ciphertext); $app->wechat->success(); break; + default: + Log::error('支付回调失败,订单号:' . $ciphertext['out_trade_no'], $ciphertext); + break; } } } else { if ($result && $result->event_type == 'REFUND.SUCCESS') { $ciphertext = $result->resource['ciphertext']; - Cache::set('7logC'.time(),json_encode($ciphertext)); + Cache::set('7logC' . time(), json_encode($ciphertext)); if ($ciphertext['refund_status'] === 'SUCCESS') { //处理订单 -1判断是退的一单还是拆分的订单 $out_trade_no = $ciphertext['out_trade_no'] . '-1'; @@ -68,7 +70,6 @@ class PayController extends BaseApiController public function wechatQuery() { $order_no = $this->request->get('order_no'); - $recharge = $this->request->get('recharge', 0); $order = [ 'out_trade_no' => $order_no, ]; @@ -77,13 +78,22 @@ class PayController extends BaseApiController try { $res = $app->wechat->query($order); } catch (\Exception $e) { - return $this->fail($e->extra['message']); + return $this->fail($e->extra['message'] ?? $e->getMessage()); } if ($res['trade_state'] == 'SUCCESS' && $res['trade_state_desc'] == '支付成功') { - if ($recharge == 0) { - PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); - } else { - PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + $attach = $res['attach']; + switch ($attach) { + case 'recharge': + PayNotifyLogic::handle('recharge', $res['out_trade_no'], $res); + $app->wechat->success(); + break; + case 'wechat_common': + PayNotifyLogic::handle('wechat_common', $res['out_trade_no'], $res); + $app->wechat->success(); + break; + default: + Log::error('支付回调失败,订单号:' . $res['out_trade_no'], $res); + break; } return $this->success('支付成功'); } else { diff --git a/app/api/controller/store/StoreController.php b/app/api/controller/store/StoreController.php index 61410d88..5872c05f 100644 --- a/app/api/controller/store/StoreController.php +++ b/app/api/controller/store/StoreController.php @@ -14,6 +14,7 @@ use app\common\logic\PaymentLogic; use app\common\logic\PayNotifyLogic; use app\common\model\Config; use app\common\model\user\User; +use app\common\model\user\UserAddress; use app\common\model\user_create_log\UserCreateLog; use app\common\model\user_recharge\UserRecharge; use support\Cache; @@ -84,13 +85,31 @@ class StoreController extends BaseApiController if(!$find){ $params['create_uid']=$this->userId; $find=UserUserLogic::StoreAdd($params); + if(UserUserLogic::hasError()){ + return $this->fail(UserUserLogic::getError()); + } }else{ $find['real_name']=$params['real_name']; $find['label_id']=$params['label_id']??0; $find->save(); - } - if($find === false){ - return $this->fail(UserUserLogic::getError()); + $adds=UserAddress::where('uid',$find['id'])->find(); + $adds_data=[ + 'uid' => $find['id'], + 'real_name' => $params['real_name']??"", + 'mobile' => $params['mobile']??'', + 'province' => $params['province']??'', + 'city' => $params['city']??'', + 'area' => $params['area']??'', + 'street' => $params['street']??'', + 'village' => $params['village']??'', + 'brigade' => $params['brigade']??'', + 'is_default' => 1, + ]; + if($adds){ + $adds->save($adds_data); + }else{ + UserAddress::create($adds_data); + } } if($recharge_type!='INDUSTRYMEMBERS'){ return $this->success('添加用户成功'); @@ -108,6 +127,7 @@ class StoreController extends BaseApiController $order = UserRecharge::create($data); $order['pay_price']=$order['price']; + $order['attach']=$order['recharge']; $result = PaymentLogic::codepay($auth_code, $order,'条码支付'); if (PaymentLogic::hasError()) { return $this->fail(PaymentLogic::getError()); @@ -136,6 +156,7 @@ class StoreController extends BaseApiController UserRecharge::where('id', $id)->update(['order_id'=>$order_id]); $order['order_id']=$order_id; $order['pay_price']=$order['price']; + $order['attach']=$order['recharge']; $result = PaymentLogic::codepay($auth_code, $order,'条码支付'); if (PaymentLogic::hasError()) { return $this->fail(PaymentLogic::getError()); diff --git a/app/api/controller/user/UserRechargeController.php b/app/api/controller/user/UserRechargeController.php index ba97d6a5..95ebf071 100644 --- a/app/api/controller/user/UserRechargeController.php +++ b/app/api/controller/user/UserRechargeController.php @@ -10,7 +10,6 @@ use app\api\lists\user\UserRechargeLists; class UserRechargeController extends BaseApiController { - /** * @notes 获取用户充值 * @return \support\Response @@ -21,4 +20,40 @@ use app\api\lists\user\UserRechargeLists; { return $this->dataLists(new UserRechargeLists()); } + + public function recharge_list() + { + $buy_bar = "元采购包"; + $send_bar = "品牌礼品券"; + $arr = [ + [ + 'money'=>1000,//采购包 + 'send'=>249,//礼品券 + 'money_string'=>$buy_bar, + 'send_string'=>$send_bar, + ], + [ + 'money'=>2000,//采购包 + 'send'=>560,//礼品券 + 'money_string'=>$buy_bar, + 'send_string'=>$send_bar, + ], + [ + 'money'=>5000,//采购包 + 'send'=>1550,//礼品券 + 'money_string'=>$buy_bar, + 'send_string'=>$send_bar, + ], + [ + 'money'=>10000,//采购包 + 'send'=>3500,//礼品券 + 'money_string'=>$buy_bar, + 'send_string'=>$send_bar, + ] + ]; + return $this->success('ok',$arr); + + + } + } diff --git a/app/api/controller/user_ship/UserShipController.php b/app/api/controller/user_ship/UserShipController.php index f6b2b9c4..3e6afa1b 100644 --- a/app/api/controller/user_ship/UserShipController.php +++ b/app/api/controller/user_ship/UserShipController.php @@ -2,7 +2,7 @@ namespace app\api\controller\user_ship; - +use app\admin\logic\user_ship\UserShipLogic; use app\api\controller\BaseApiController; use app\common\lists\user\UserShipLists; @@ -28,4 +28,13 @@ class UserShipController extends BaseApiController } + public function is_user_ship(){ + $data=$this->request->post(); + UserShipLogic::user_ship($data); + if(UserShipLogic::hasError()){ + return $this->fail(UserShipLogic::getError()); + }else{ + return $this->success('ok'); + } + } } \ No newline at end of file diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index d46a2133..e71bcf78 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -112,6 +112,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists 'pay_price' => $this->total_price ]; if($this->off_activity==1){ + $this->activity_price = $this->total_price; $data['pay_price']=$this->activity_price; if($this->activity_price<500){ $data['msg']='还差'.bcsub(500,$this->activity_price,2).'即可获得10%的品牌礼品兑换券,可到线下门店兑换礼品。'; diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 422e9620..81be9bb8 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -117,19 +117,19 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L public function extend() { $off_activity = Config::where('name', 'off_activity')->value('value'); - if($off_activity==1){ - $data=[ - 'off_activity' => $off_activity, - 'price' => 'cost', - 'op_price' => 'price', - ]; - }else{ +// if($off_activity==1){ +// $data=[ +// 'off_activity' => $off_activity, +// 'price' => 'cost', +// 'op_price' => 'price', +// ]; +// }else{ $data=[ 'off_activity' => $off_activity, 'price' => 'price', 'op_price' => 'price', ]; - } +// } return $data; } } diff --git a/app/api/lists/user_create_log/UserCreateLogLists.php b/app/api/lists/user_create_log/UserCreateLogLists.php index fc9d05a7..aad9deb9 100644 --- a/app/api/lists/user_create_log/UserCreateLogLists.php +++ b/app/api/lists/user_create_log/UserCreateLogLists.php @@ -45,6 +45,7 @@ class UserCreateLogLists extends BaseAdminDataLists implements ListsSearchInterf */ public function lists(): array { + $this->searchWhere['user_ship'] =4; $data = UserCreateLog::where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 9a997a7b..582db789 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic self::$cost = 0; //成本由采购价替代原成本为门店零售价 self::$profit = 0; //利润 self::$activity_price = 0; //活动减少 - self::$store_price = 0; //门店零售价 + self::$store_price = 0; //商户价 self::$deduction_price =0; $deduction_price = 0; //抵扣金额 /** 计算价格 */ @@ -91,20 +91,21 @@ class OrderLogic extends BaseLogic } unset($cart_select[$k]['id']); $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 - if ($off_activity == 1) { - $price = $find['cost']; - } else { +// if ($off_activity == 1) { +// $price = $find['cost']; +// } else { $price = $find['price']; - } +// } $cart_select[$k]['price'] = $price; $cart_select[$k]['cost'] = $find['cost']; $cart_select[$k]['vip'] = 0; + $cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name')??''; //单位名称 //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 $cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本 $cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额 - $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //门店零售价 + $cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价 $cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价 if($cart_select[$k]['total_price']>$cart_select[$k]['pay_price']){ $deduction_price=bcsub($cart_select[$k]['total_price'],$cart_select[$k]['pay_price'],2); @@ -114,9 +115,17 @@ class OrderLogic extends BaseLogic $cart_select[$k]['old_cart_id'] = $v['id']; $cart_select[$k]['cart_num'] = $v['cart_num']; $cart_select[$k]['verify_code'] = $params['verify_code'] ?? ''; - //vip1待返回金额 - $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'], $cart_select[$k]['vip_price'], 2); - + $cart_select[$k]['vip_frozen_price']=0; + //会员待返回金额 + if ($user && $off_activity==0){ + if($user['user_ship']==4){ + //商户 + $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'], $cart_select[$k]['store_price'], 2); + }else{ + //其他会员 + $cart_select[$k]['vip_frozen_price'] = bcsub($cart_select[$k]['pay_price'],$cart_select[$k]['vip_price'], 2); + } + } // d($cart_select[$k]['pay_price'],$cart_select[$k]['store_price'],$cart_select[$k]['vip_price'] ); $cartInfo = $cart_select[$k]; $cartInfo['name'] = $find['store_name']; @@ -131,22 +140,17 @@ class OrderLogic extends BaseLogic self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2); self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2); self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2); - self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //门店零售价格 + self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价 self::$deduction_price=bcadd(self::$deduction_price,$deduction_price,2);//抵扣金额 // self::$profit = bcadd(self::$profit, $cart_select[$k]['profit'], 2); } //加支付方式限制 - $pay_type = isset($params['pay_type']) ? $params['pay_type'] : 0; - if ($user && $user['user_ship'] == 1 && $pay_type != 17) { - $pay_price = self::$pay_price; - } else { + // $pay_type = isset($params['pay_type']) ? $params['pay_type'] : 0; + // if ($user && $user['user_ship'] == 1 && $pay_type != 17) { + // $pay_price = self::$pay_price; + // } else { $pay_price = bcsub(self::$pay_price, self::$activity_price, 2); //减去活动优惠金额 - } - - // if($pay_price < 500){ - // throw new Exception('金额低于500'); - // } - + // } //成本价 收益 $order = [ 'create_time' => time(), @@ -176,24 +180,38 @@ class OrderLogic extends BaseLogic $order['source'] = $params['source']; } //处理返回最近的店铺 - if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { - $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); - $nearestStore = null; - $minDistance = PHP_FLOAT_MAX; - foreach ($storeAll as $value) { - $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $params['lat'], $params['long']); - if ($value['distance'] < $minDistance) { - $minDistance = $value['distance']; - $nearestStore = $value; - } - } - $store['near_store'] =[]; - if ($nearestStore) { - $store['near_store'] = $nearestStore; - } - }else{ + $store_check = 0; + if(empty($user)){ $store_id = getenv('STORE_ID') ?? 1; $store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; + }else{ + $checkOrderStore = StoreOrder::where('uid',$user['id'])->field('id,store_id') + ->order('id','desc')->find(); + if($checkOrderStore){ + $store['near_store'] =SystemStore::where('id', $checkOrderStore['store_id'])->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; + $store_check = 1; + }else{ + $store_id = getenv('STORE_ID') ?? 1; + $store['near_store'] =SystemStore::where('id', $store_id)->field('id,name,phone,address,detailed_address,latitude,longitude')->find()??[]; + } + } + if (empty($store_check)) { + if ((isset($params['lat']) && $params['lat'] != '') && (isset($params['long']) && $params['long'] != '')) { + $storeAll = SystemStore::field('id,name,phone,address,detailed_address,latitude,longitude')->select()->toArray(); + $nearestStore = null; + $minDistance = PHP_FLOAT_MAX; + foreach ($storeAll as $value) { + $value['distance'] = haversineDistance($value['latitude'], $value['longitude'], $params['lat'], $params['long']); + if ($value['distance'] < $minDistance) { + $minDistance = $value['distance']; + $nearestStore = $value; + } + } + $store['near_store'] =[]; + if ($nearestStore) { + $store['near_store'] = $nearestStore; + } + } } } catch (\Exception $e) { self::setError($e->getMessage()); @@ -534,11 +552,7 @@ class OrderLogic extends BaseLogic $money = $financeFlow->where(['order_id' => $order['id'], 'financial_pm' => 1, 'financial_type' => 2])->value('number') ?? 0; $financeFlowLogic->updateStatusStore($order['id'], $order['store_id'], $money, $deposit); //积分结算 - $user_ship=-1; - if($order['uid']){ - $user_ship=User::where('id',$order['uid'])->value('user_ship'); - } - if($order['is_storage']==0&&$order['source']==0&&in_array($user_ship,[0,4])){ + if($order['is_storage']==0&&$order['source']==0){ UserSignLogic::WriteOff($order); } Db::commit(); diff --git a/app/api/logic/user/AddressLogic.php b/app/api/logic/user/AddressLogic.php index a7b8b59f..e7861c3e 100644 --- a/app/api/logic/user/AddressLogic.php +++ b/app/api/logic/user/AddressLogic.php @@ -63,11 +63,11 @@ class AddressLogic extends BaseLogic if($is_default==1){ UserAddress::where('uid',$params['uid'])->update(['is_default'=>0]); } + $find=UserAddress::where('uid', $params['uid'])->where('id', $params['id'])->find(); $data = [ 'real_name' => $params['real_name'], 'phone' => $params['phone'], 'detail' => $params['detail']??'', - 'is_default' => $params['is_default']??0, 'detail' => $params['detail']??'', 'is_default' => $params['is_default']??0, 'province' => $params['province'], @@ -77,7 +77,14 @@ class AddressLogic extends BaseLogic 'village' => $params['village'], 'brigade' => $params['brigade'], ]; - UserAddress::where('uid', $params['uid'])->where('id', $params['id'])->update($data); + if($find){ + UserAddress::where('uid', $params['uid'])->where('id', $params['id'])->update($data); + }else{ + $data['is_default']=1; + $data['uid']=$params['uid']; + UserAddress::create($data); + } + Db::commit(); return true; } catch (\Exception $e) { diff --git a/app/api/logic/user/UserLogic.php b/app/api/logic/user/UserLogic.php index 67b4ee75..ef5a9590 100644 --- a/app/api/logic/user/UserLogic.php +++ b/app/api/logic/user/UserLogic.php @@ -257,13 +257,13 @@ class UserLogic extends BaseLogic switch ($params['type']){ case 1: //采购款明细 - $categories = ['user_balance_recharge', 'user_order_purchase_pay','system_purchase_add']; + $categories = ['user_balance_recharge', 'user_order_purchase_pay','system_purchase_add','user_balance_recharge_refund']; $query = CapitalFlow::where('uid', $uid) ->whereIn('category', $categories); - if($params['mark'] == 1){ + if(isset($params['mark'])&&$params['mark'] == 1){ $query->where('type','in'); } - if($params['mark'] == 2){ + if(isset($params['mark'])&&$params['mark'] == 2){ $query->where('type','out'); } $count = $query->count(); @@ -330,6 +330,15 @@ class UserLogic extends BaseLogic ->page($params['page_no'],$params['page_size']) ->order('id','desc') ->select()->toArray(); + foreach ($data as &$value){ + if($value['status'] == 0){ + $value['title'] = "购买商品".$value['all']."元获得".$value['number']."元返还金"; + }else{ + //退回到余额、微信、采购款 + $back = self::dealTitleCate($value['pay_type']); + $value['title'] = "返还金解冻".$value['number']."元退回到".$back; + } + } break; default: $data = []; @@ -344,5 +353,31 @@ class UserLogic extends BaseLogic } + public static function dealTitleCate($pay_type) + { + switch ($pay_type){ + case 18: + $title = "采购款"; + break; + case 17: + $title = "现金"; + break; + case 3: + $title ="余额"; + break; + case 7: + case 9: + $title ="微信"; + break; + case 13: + $title ="支付宝"; + break; + default: + $title ="默认"; + } + return $title; + } + + } \ No newline at end of file diff --git a/app/common/logic/CapitalFlowLogic.php b/app/common/logic/CapitalFlowLogic.php index a49be021..2e14a6e8 100644 --- a/app/common/logic/CapitalFlowLogic.php +++ b/app/common/logic/CapitalFlowLogic.php @@ -30,7 +30,7 @@ class CapitalFlowLogic extends BaseLogic * @param $mark * @return mixed */ - public function userIncome($category, $linkType, $linkId, $amount, $mark = '',$type=0) + public function userIncome($category, $linkType, $linkId, $amount, $mark = '', $type = 0) { $model = new CapitalFlow(); $model->uid = $this->user['id']; @@ -38,10 +38,10 @@ class CapitalFlowLogic extends BaseLogic $model->link_type = $linkType; $model->link_id = $linkId; $model->amount = $amount; - if($type){ + if ($type) { $model->before_balance = $this->user['purchase_funds']; $model->balance = bcadd($this->user['purchase_funds'], $amount, 2); - }else{ + } else { $model->before_balance = $this->user['now_money']; $model->balance = bcadd($this->user['now_money'], $amount, 2); } @@ -63,7 +63,7 @@ class CapitalFlowLogic extends BaseLogic * @param $mark * @return mixed */ - public function userExpense($category, $linkType, $linkId, $amount, $mark = '',$payType=0,$store_id=0) + public function userExpense($category, $linkType, $linkId, $amount, $mark = '', $payType = 0, $store_id = 0) { $model = new CapitalFlow(); $model->uid = $this->user['id']; @@ -72,13 +72,13 @@ class CapitalFlowLogic extends BaseLogic $model->link_type = $linkType; $model->link_id = $linkId; $model->amount = $amount; - if($payType == OrderEnum::BALANCE_PAYMEN_NO){ + if ($payType == OrderEnum::BALANCE_PAYMEN_NO) { $model->before_balance = $this->user['purchase_funds']; $model->balance = bcsub($this->user['purchase_funds'], $amount, 2); - }else{ - $model->before_balance = $this->user['now_money']; - $model->balance = bcsub($this->user['now_money'], $amount, 2); - } + } else { + $model->before_balance = $this->user['now_money']; + $model->balance = bcsub($this->user['now_money'], $amount, 2); + } $model->create_time = date('Y-m-d H:i:s'); $model->type = 'out'; $model->title = $this->getTitle($category, $amount); @@ -171,9 +171,10 @@ class CapitalFlowLogic extends BaseLogic return "系统增加采购款{$amount}元"; case 'system_balance_reduce': return "系统减少余额{$amount}元"; + case 'user_balance_recharge_refund': + return "用户充值退还{$amount}元"; default: return "订单支付{$amount}元"; } } - } diff --git a/app/common/logic/CommissionLogic.php b/app/common/logic/CommissionLogic.php index f866f4a8..3cb73f88 100644 --- a/app/common/logic/CommissionLogic.php +++ b/app/common/logic/CommissionLogic.php @@ -49,11 +49,9 @@ class CommissionLogic extends BaseLogic $user_1 = self::user($order, 0.07, $transaction_id, $order['spread_uid'], 12); //会员、厨师 $user_2 = self::user($order, 0.01, $transaction_id, $village_uid, 14); //村长 $user_3 = self::user($order, 0.01, $transaction_id, $brigade_uid, 15); //队长 - $platform = self::platform($order, 0.02, $transaction_id); //平台 $store = self::store($order, 0.05, $transaction_id, 0); //门店 $attrition = self::attrition($order, 0.02,$transaction_id,16); //损耗 - $moeny = bcadd(bcadd(bcadd(bcadd($user_1, $user_2, 2), $user_3, 2), $platform, 2), bcadd($store, $attrition, 2), 2); self::suppliter($order, $moeny, $transaction_id); } @@ -79,7 +77,11 @@ class CommissionLogic extends BaseLogic $financeLogic = new StoreFinanceFlowLogic(); $financeLogic->order = $order; $financeLogic->user['uid'] = $order['uid']; - $fees = bcdiv(bcmul($order['pay_price'], $platformRate, 2), 1, 2); + $pay_price = $order['pay_price']; + if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ + $pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); + } + $fees = bcdiv(bcmul($pay_price, $platformRate, 2), 1, 2); if ($fees > 0) { $financeLogic->in($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //平台手续费 $financeLogic->out($transaction_id, $fees, OrderEnum::ORDER_HANDLING_FEES, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //商户平台手续费支出 @@ -95,7 +97,11 @@ class CommissionLogic extends BaseLogic $financeLogic = new StoreFinanceFlowLogic(); $financeLogic->order = $order; $financeLogic->user['uid'] = $order['uid']; - $fees = bcsub($order['pay_price'], $platformRate, 2); + $pay_price = $order['pay_price']; + if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ + $pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); + } + $fees = bcsub($pay_price, $platformRate, 2); if ($fees > 0) { $financeLogic->in($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); @@ -116,7 +122,11 @@ class CommissionLogic extends BaseLogic //缴纳齐全了就加商户没有就加到平台 $money_limt = SystemStore::where('id', $order['store_id'])->field('paid_deposit,security_deposit')->find(); $deposit = bcsub($money_limt['security_deposit'], $money_limt['paid_deposit'], 2); //保证金剩余额度 - $store_profit = bcmul($order['pay_price'], $platformRate, 2); + $pay_price = $order['pay_price']; + if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ + $pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); + } + $store_profit = bcmul($pay_price, $platformRate, 2); if ($deposit > 0) { if ($deposit > $store_profit) { if ($store_profit > 0) { @@ -151,7 +161,11 @@ class CommissionLogic extends BaseLogic public static function user($order, $userRate, $transaction_id, $uid = 0, $enum = 0) { $financeLogic = new StoreFinanceFlowLogic(); - $fees = bcmul($order['pay_price'], $userRate, 2); + $pay_price = $order['pay_price']; + if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ + $pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); + } + $fees = bcmul($pay_price, $userRate, 2); if ($fees > 0) { //记录用户余额收入 if ($uid) { @@ -177,7 +191,11 @@ class CommissionLogic extends BaseLogic $financeLogic = new StoreFinanceFlowLogic(); $financeLogic->order = $order; $financeLogic->user['uid'] = $order['uid']; - $fees = bcmul($order['pay_price'], $userRate, 2); + $pay_price = $order['pay_price']; + if(isset($order['dealVipAmount']) &&$order['dealVipAmount']>0){ + $pay_price=bcsub($order['pay_price'],$order['dealVipAmount'],2); + } + $fees = bcmul($pay_price, $userRate, 2); if ($fees > 0) { SystemStore::where('id', $order['store_id'])->inc('attrition', $fees)->update(); $financeLogic->in($transaction_id, $fees, $enum, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 889d6a2a..67bbe2a7 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -114,9 +114,12 @@ class PayNotifyLogic extends BaseLogic ]; OrderLogic::writeOff($params); } + if(in_array($order['shipping_type'],[1,2])){ + PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); + } return true; // Redis::send('push-platform-print', ['id' => $order['id']], 60); - // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); + } /** @@ -225,160 +228,10 @@ class PayNotifyLogic extends BaseLogic self::dealGoodsLeft($checkArr, $order['uid'], $order['id']); } - // $count = UserSign::where([ - // 'uid'=>$order['uid'], - // 'type'=>1, - // 'status'=>0 - // ])->count(); - // - // if($count){ - // self::addFlowLog($order); - // } - //收银台下单直接到账 - // if($order['shipping_type'] == 3){ - // self::descStock($order['id']); - // } - - // Redis::send('push-platform-print', ['id' => $order['id']], 60); - // PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); - } - - //采购款支付后如果有对应的冻结的话就去反对应的log - public static function addFlowLog($order) - { - //查询当前用户有无对应的充值的冻结金额 - if ($order['uid'] > 0) { - $query = UserSign::where([ - 'uid' => $order['uid'], - 'type' => 1, - 'status' => 0 - ]); - // $query1 = clone $query; - // $ids = $query->column('id'); - $check = $query->sum('number'); - // $count = $query1->count(); - if ($check && $check > 0) { - $backPurchase = bcmul($order['pay_price'], 0.1, 2); - - // if($count == 1){ - //存在拆单子否 - //少了就冻结减去这个对应的金额 - $one = UserSign::where([ - 'uid' => $order['uid'], - 'type' => 1, - 'status' => 0 - ])->find(); - $data = [ - 'sid' => $one['id'], - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '充值获得冻结兑换券', - 'financial_pm' => 1, - 'type' => 1, - 'status' => 1, - ]; - - if ($one['number'] >= $backPurchase) { - // $wait = bcsub($one['number'],$backPurchase,2)??0; - $data['number'] = $backPurchase; - - Db::name('user_sign_log')->insert($data); - - //总的减去采购款百分之十剩余的 - // if(empty($wait)){ - // UserSign::where('id',$one['id'])->update( - // [ - // 'number'=>0, - // 'status'=>1 - // ] - // ); - // }else{ - // //add - // UserSign::where('id',$one['id'])->update( - // [ - // 'number'=>$wait - // ] - // ); - // } - - //并且加到对应的用户的采购款中 - // User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); - } else { - //对比采购款支付的多少 多了就拿冻结金额即可 - $data['number'] = $one['number']; - //都存到对应的log日志 - Db::name('user_sign_log')->insert($data); - // UserSign::where('id',$one['id'])->update( - // [ - // 'number'=>0, - // 'status'=>1 - // ] - // ); - //并且加到对应的用户的采购款中 - // User::where('id',$order['uid'])->inc('purchase_funds',$wait)->update(); - } - } - /* else{ - //大于0的时候 - //先处理金额大的再处理剩余的 - //把所有的金额改为正的再加一条后再加 - UserSign::where([ - 'uid'=>$order['uid'], - 'type'=>1, - 'status'=>0 - ])->update([ - 'status'=>1, - 'title'=>json_encode($ids) - ]); - if ($check >= $backPurchase) { - //补一条待解冻的 - $left = bcsub($check,$backPurchase,2); - if($left > 0){ - $data = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '补冻结兑换券', - 'financial_pm' => 0, - 'type' => 1, - ]; - $data['number'] =$check; - $sid = Db::name('user_sign')->insertGetId($data); - - $data = [ - 'uid' => $order['uid'], - 'sid' => $sid, - 'order_id' => $order['order_id'], - 'title' => '充值获得冻结兑换券', - 'financial_pm' => 1, - 'type' => 1, - ]; - $data['number'] =$backPurchase; - Db::name('user_sign_log')->insert($data); - } -// User::where('id',$order['uid'])->inc('purchase_funds',$backPurchase)->update();//add - - }else{ - //log - $data = [ - 'uid' => $order['uid'], - 'order_id' => $order['order_id'], - 'title' => '充值获得冻结兑换券', - 'financial_pm' => 1, - 'type' => 1, - ]; - $data['number'] =$check; - Db::name('user_sign_log')->insert($data); -// User::where('id',$order['uid'])->inc('purchase_funds',$check)->update();//add - } - - }*/ - - // } - return true; + if(in_array($order['shipping_type'],[1,2])){ + PushService::push('store_merchant_' . $order['store_id'], $order['store_id'], ['type' => 'store_merchant', 'msg' => '您有一笔新的订单']); } - - return true; } /** @@ -455,10 +308,10 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao = new CapitalFlowLogic($user); if ($purchase_funds >= $orderRe['price']) { User::where('id', $orderRe['uid'])->dec('purchase_funds', $orderRe['refund_price'])->update(); - $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $orderRe['refund_price'], '', 1, $orderRe['store_id']); + $capitalFlowDao->userExpense('user_balance_recharge_refund', 'order', $orderRe['id'], $orderRe['refund_price'], '', 1, $orderRe['store_id']); } else { User::where('id', $orderRe['uid'])->dec('purchase_funds', $purchase_funds)->update(); - $capitalFlowDao->userExpense('user_order_purchase_pay', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']); + $capitalFlowDao->userExpense('user_balance_recharge_refund', 'order', $orderRe['id'], $purchase_funds, '', 1, $orderRe['store_id']); } //退还 充值得兑换券 UserSignLogic::RefundRecharge($orderRe); @@ -715,6 +568,7 @@ class PayNotifyLogic extends BaseLogic $village_uid = 0; $brigade_uid = 0; $user_ship = 0; + $order['dealVipAmount'] = 0; try { Redis::send('order_wetcha_push_send', ['order' => $order]); } catch (\Exception $e) { @@ -729,7 +583,7 @@ class PayNotifyLogic extends BaseLogic } //积分写入 - if(in_array($user_ship,[0,4])){ + if(in_array($order['pay_type'],[3,7,9,13,17])&&$order['uid']>0){ UserSignLogic::OrderWrite($order); } if ($off_activity == 1) { @@ -743,12 +597,9 @@ class PayNotifyLogic extends BaseLogic return false; } - //纯在分销关系的时候要去判断分销出来的用户的采购款的额度 (只有会员按照这个逻辑拆分,其余的还是按照正常的支付金额) - if ($user_ship== 1 && $order['pay_type'] != PayEnum::CASH_PAY) { - $vipFrozenAmount = self::dealFrozenPrice($order['id']); - //为1的时候要去减活动价 - $order['pay_price'] = bcsub($order['pay_price'], $vipFrozenAmount, 2); - self::dealVipAmount($order, $order['pay_type']); + //如果是会员需要返回会员金额 + if ($user_ship>0 && $order['pay_type'] != PayEnum::CASH_PAY && $off_activity !=1) { + $order['dealVipAmount']= self::dealVipAmount($order, $order['pay_type']); } if ($order['spread_uid'] > 0 || $user_ship > 0) { if ($order['spread_uid'] > 0 && $user_ship == 0) { @@ -787,8 +638,12 @@ class PayNotifyLogic extends BaseLogic } } switch ($user_ship) { - case 1: // 行业会员 + case 1: // 厨师 case 4: // 商户 + case 5: // 种养殖 + case 6: // 酒店 + case 7: // 食堂 + case 8: // 一条龙 CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id); break; case 2: // 村长 @@ -865,6 +720,7 @@ class PayNotifyLogic extends BaseLogic 'order_sn' => $order['order_id'], 'user_id' => $order['uid'], 'number' => $total_vip, + 'all' => $order['pay_price'], 'pay_type' => $pay_type ?? 1, 'status' => 0, 'store_id' => $order['store_id'], @@ -872,7 +728,7 @@ class PayNotifyLogic extends BaseLogic 'create_time' => time() ]; Db::name('vip_flow')->insert($data); - return true; + return $total_vip; } /** diff --git a/app/common/logic/PaymentLogic.php b/app/common/logic/PaymentLogic.php index a49df640..322cc442 100644 --- a/app/common/logic/PaymentLogic.php +++ b/app/common/logic/PaymentLogic.php @@ -83,7 +83,7 @@ class PaymentLogic extends BaseLogic self::$error = '请使用正确的微信收付款条码'; return false; } - $order = [ + $data = [ 'description' => $description, 'out_trade_no' => (string)$order['order_id'], 'payer' => [ @@ -97,10 +97,14 @@ class PaymentLogic extends BaseLogic 'id' => (string)$order['store_id']??1 ] ], + 'attach'=>'wechat_common' ]; + if(isset($order['attach']) && $order['attach']!=''){ + $data['attach'] = $order['attach']; + } $wechat = new PayService(1); try { - $result = $wechat->wechat->pos($order)->toArray(); + $result = $wechat->wechat->pos($data)->toArray(); } catch (Exception $e) { Log::error('条码支付报错',['message' => $e->extra['message']?? $e->getMessage(),'code'=>$e->getCode()]); diff --git a/app/common/logic/UserSignLogic.php b/app/common/logic/UserSignLogic.php index fc7e6379..75139fac 100644 --- a/app/common/logic/UserSignLogic.php +++ b/app/common/logic/UserSignLogic.php @@ -5,6 +5,7 @@ namespace app\common\logic; use app\common\logic\BaseLogic; use app\common\model\user\User; +use app\common\model\user_recharge\UserRecharge; use app\common\model\user_sign\UserSign; use app\common\model\user_sign_log\UserSignLog; @@ -20,9 +21,29 @@ class UserSignLogic extends BaseLogic */ public static function dealRechargeFrozen($user, $order, $user_ship = 0) { - $total_vip = bcmul($order['price'], 0.1, 2); - $count = UserSign::where('uid', $order->uid)->count(); - if ($count == 0 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { + $price=(int)$order['price']; + switch ($price) { + case 1000: + $total_vip = 249; + break; + case 2000: + $total_vip = 560; + break; + case 5000: + $total_vip = 1550; + break; + case 10000: + $total_vip = 3500; + break; + default: + $total_vip = 0; + break; + } + if($total_vip==0){ + return false; + } + $count = UserRecharge::where('uid', $order->uid)->count(); + if ($count ==1 && in_array($user_ship, [1, 2, 3, 5, 6, 7, 8])) { //首充 $write = self::write($order, $total_vip, 0, 1, 9); self::write_log($write, $total_vip, 0, 7); diff --git a/app/common/logic/store_order/StoreOrderLogic.php b/app/common/logic/store_order/StoreOrderLogic.php index 1ae87783..88adab80 100644 --- a/app/common/logic/store_order/StoreOrderLogic.php +++ b/app/common/logic/store_order/StoreOrderLogic.php @@ -239,6 +239,9 @@ class StoreOrderLogic extends BaseLogic $order['refund_status_name'] = OrderEnum::refundStatus($order['refund_status']) ?? ''; $order['refund_type_name'] = OrderEnum::refundType($order['refund_type']) ?? ''; $order['pay_type_name'] =PayEnum::getPaySceneDesc($order['pay_type']) ?? ''; + if($order['pay_type'] == PayEnum::PURCHASE_FUNDS && in_array($order['shipping_type'],[1,2])){ + $order['pay_type_name'] = "采购款"; + } if ($order['pay_type'] == 19){ $order['deduction_price'] = "0.00"; } diff --git a/app/common/model/store_product_gift/StoreProductGift.php b/app/common/model/store_product_gift/StoreProductGift.php new file mode 100644 index 00000000..a4e1c07a --- /dev/null +++ b/app/common/model/store_product_gift/StoreProductGift.php @@ -0,0 +1,34 @@ +hasOne(SystemStore::class, 'id', 'store_id') + ->bind(['store_name' => 'name', 'store_phone' => 'phone', 'store_detailed_address' => 'detailed_address', 'store_simple_address' => 'address']); + } + + public function user() + { + return $this->hasOne(User::class, 'id', 'uid')->bind(['nickname', 'avatar', 'mobile']); + } + + public function goodsName() + { + return $this->hasOne(StoreProduct::class,'id','product_id')->bind(['goods_name'=>'store_name','image','unit','price']); + } + +} \ No newline at end of file diff --git a/app/statistics/logic/OrderLogic.php b/app/statistics/logic/OrderLogic.php index 27465376..afdfe3bb 100644 --- a/app/statistics/logic/OrderLogic.php +++ b/app/statistics/logic/OrderLogic.php @@ -69,10 +69,11 @@ class OrderLogic extends BaseLogic public static function dealFlexiblePrice($where,$start,$end) { - $todayAmount = UserRecharge::where($where) + //排除退款 + $todayAmount = UserRecharge::where($where)->where('status',1) ->whereBetweenTime('create_time', $start, $end) ->sum('price'); - $pay_price = StoreOrder::where($where) + $pay_price = StoreOrder::where($where)->where('refund_status',0) ->whereBetweenTime('create_time', $start, $end) ->sum('pay_price'); return bcadd($todayAmount, $pay_price, 2); diff --git a/app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php b/app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php index 28042550..9f859947 100644 --- a/app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php +++ b/app/store/controller/store_cash_finance_flow/StoreCashFinanceFlowController.php @@ -55,10 +55,10 @@ class StoreCashFinanceFlowController extends BaseAdminController { $params = (new StoreCashFinanceFlowValidate())->goCheck('detail'); $result = StoreCashFinanceFlowLogic::detail($params); - $result['image']='https://lihaiim.oss-cn-chengdu.aliyuncs.com/public/uploads/images/20240619/20240619104553f7e108704.jpg'; - $result['bank_code']='456565656'; - $result['bank_name']='里海农科'; - $result['bank_address']='泸州支行'; + $result['image']='https://lihaiim.oss-cn-chengdu.aliyuncs.com/public/uploads/images/20240703/20240703101919cf8429391.jpg'; + $result['bank_code']='22170201040004200'; + $result['bank_name']='泸县供投里海农业科技有限公司'; + $result['bank_address']='中国农业银行股份有限公司泸州石洞支行'; return $this->data($result); } diff --git a/app/store/controller/store_order/StoreOrderController.php b/app/store/controller/store_order/StoreOrderController.php index 17e1f8c1..c3fdfe54 100644 --- a/app/store/controller/store_order/StoreOrderController.php +++ b/app/store/controller/store_order/StoreOrderController.php @@ -3,6 +3,7 @@ namespace app\store\controller\store_order; use app\admin\logic\user\UserLogic; +use app\admin\logic\user_ship\UserShipLogic; use app\api\logic\order\OrderLogic; use app\api\validate\OrderValidate; use app\common\model\order\Cart; @@ -398,6 +399,10 @@ class StoreOrderController extends BaseAdminController return $this->fail('支付条码不能为空'); } $params = $this->request->post(); + UserShipLogic::user_ship($params); + if(UserShipLogic::hasError()){ + return $this->fail(UserShipLogic::getError()); + } $data = [ 'store_id' => $this->adminInfo['store_id'], 'uid' => $params['uid'], diff --git a/app/store/controller/user/AddressController.php b/app/store/controller/user/AddressController.php index 5563dc14..e53884d8 100644 --- a/app/store/controller/user/AddressController.php +++ b/app/store/controller/user/AddressController.php @@ -22,10 +22,11 @@ class AddressController extends BaseAdminController public function edit() { $params = (new UserAddressValidate())->post()->goCheck('edit'); - if(AddressLogic::edit($params)){ - return $this->success('编辑成功'); - }else{ + AddressLogic::edit($params); + if(AddressLogic::hasError()){ return $this->fail(AddressLogic::getError()); + }else{ + return $this->success('编辑成功'); } } /** diff --git a/app/store/controller/user/UserController.php b/app/store/controller/user/UserController.php index 47e6b865..6679b6b1 100644 --- a/app/store/controller/user/UserController.php +++ b/app/store/controller/user/UserController.php @@ -9,6 +9,7 @@ use app\store\controller\BaseAdminController; use app\store\lists\user\UserLists; use app\admin\logic\user\UserLogic; use app\admin\validate\user\UserValidate; +use app\api\controller\user\UserRechargeController; use app\common\model\user\User; use support\Cache; @@ -26,36 +27,34 @@ class UserController extends BaseAdminController */ public function archives_sms() { - $mobile = $this->request->post('mobile',''); + $mobile = $this->request->post('mobile', ''); if (empty($mobile)) return $this->fail('手机号缺失'); - $res = (new \app\api\logic\user\UserLogic())->dealReportingSms($mobile,'_userArchives'); - if ($res){ + $res = (new \app\api\logic\user\UserLogic())->dealReportingSms($mobile, '_userArchives'); + if ($res) { return $this->success('发送成功'); } return $this->fail('发送失败'); - } public function add() { $params = (new UserValidate())->post()->goCheck('storeAdd'); $code = $params['code']; -// if($code && $params['mobile']){ -// $remark = $params['mobile'].'_userArchives'; -// $codeCache = Cache::get($remark); -// if(empty($codeCache)){ -// return $this->fail('验证码不存在'); -// } -// if ($codeCache != $code) { -// return $this->fail('验证码错误'); -// } -// } - UserLogic::StoreAdd($params); - if (UserLogic::hasError() ) { + // if($code && $params['mobile']){ + // $remark = $params['mobile'].'_userArchives'; + // $codeCache = Cache::get($remark); + // if(empty($codeCache)){ + // return $this->fail('验证码不存在'); + // } + // if ($codeCache != $code) { + // return $this->fail('验证码错误'); + // } + // } + UserLogic::StoreAdd($params); + if (UserLogic::hasError()) { return $this->fail(UserLogic::getError()); } return $this->success('添加成功', [], 1, 1); - } public function detail() @@ -65,22 +64,28 @@ class UserController extends BaseAdminController return $this->success('', $detail); } - public function user_ship(){ - $user_ship=$this->request->post('user_ship',0); - $id=$this->request->post('id',0); - if($user_ship==1){ - return $this->fail('充值会员不能前端设置'); + public function user_ship() + { + $user_ship = $this->request->post('user_ship', 0); + $id = $this->request->post('id', 0); + if ($user_ship == 1) { + return $this->fail('充值会员不能前端设置'); } - User::where('id',$id)->update(['user_ship'=>$user_ship]); + User::where('id', $id)->update(['user_ship' => $user_ship]); return $this->success('设置成功'); } - public function user_label(){ - $label_id=$this->request->post('label_id',0); - $id=$this->request->post('id',0); + public function user_label() + { + $label_id = $this->request->post('label_id', 0); + $id = $this->request->post('id', 0); - User::where('id',$id)->update(['label_id'=>$label_id]); + User::where('id', $id)->update(['label_id' => $label_id]); return $this->success('设置成功'); } -} \ No newline at end of file + public function recharge_list() + { + return (new UserRechargeController())->recharge_list(); + } +} diff --git a/app/store/controller/user/UserShipController.php b/app/store/controller/user/UserShipController.php index e6bd8cdc..1ca0bbfe 100644 --- a/app/store/controller/user/UserShipController.php +++ b/app/store/controller/user/UserShipController.php @@ -3,7 +3,7 @@ namespace app\store\controller\user; - +use app\admin\logic\user_ship\UserShipLogic; use app\store\controller\BaseAdminController; use app\common\lists\user\UserShipLists; @@ -15,4 +15,14 @@ class UserShipController extends BaseAdminController { return $this->dataLists(new UserShipLists()); } + + public function is_user_ship(){ + $data=$this->request->post(); + UserShipLogic::user_ship($data); + if(UserShipLogic::hasError()){ + return $this->fail(UserShipLogic::getError()); + }else{ + return $this->success('ok'); + } + } } \ No newline at end of file diff --git a/app/store/lists/store_order/StoreOrderLists.php b/app/store/lists/store_order/StoreOrderLists.php index 7f1d9b8a..da9681ce 100644 --- a/app/store/lists/store_order/StoreOrderLists.php +++ b/app/store/lists/store_order/StoreOrderLists.php @@ -48,8 +48,8 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface { $store_id = $this->adminInfo['store_id'] ?? 5; $is_sashier = $this->request->get('is_sashier'); + $this->searchWhere[] = ['store_id', '=', $store_id]; if ($is_sashier == 1) { //收银台订单 - $this->searchWhere[] = ['store_id', '=', $store_id]; $this->searchWhere[] = ['source', '=', 1]; } elseif ($is_sashier == 2) { //小程序订单 $this->searchWhere[] = ['source', '=', 0]; @@ -74,7 +74,7 @@ class StoreOrderLists extends BaseAdminDataLists implements ListsSearchInterface ->field(['id', 'order_id', 'pay_price', 'pay_time','uid', 'pay_type', 'status', 'paid', 'total_num']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) - ->select()->each(function ($item) use ($store_id) { + ->select()->each(function ($item){ if (empty($item['pay_time'])) { $item['pay_time'] = ''; }else{ diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 4f3ff768..de3a9e68 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -602,7 +602,7 @@ class WorkbenchLogic extends BaseLogic //当日营业额的统计 $today = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $params['store_id']]); - $turnover_today = $today + $turnover_today = $today->where('refund_status',0) ->whereDay('create_time') ->sum('pay_price'); //当日利润的统计 @@ -629,6 +629,7 @@ class WorkbenchLogic extends BaseLogic //总的营业额的统计 总的利润的统计 总的成本合集的统计 总的加到保证金的 $all = StoreOrder::where(['paid' => YesNoEnum::YES, 'store_id' => $params['store_id']]); $deposit_all = StoreFinanceFlow::where(['store_id' => $params['store_id'], 'status' => YesNoEnum::YES]) + ->where('financial_type', OrderEnum::ORDER_MARGIN) ->sum('number'); $cash_all = StoreCashFinanceFlow::where('store_id', $params['store_id'])