From c6eebb4c1d6ba66646a528f153753f6eb781bccc Mon Sep 17 00:00:00 2001 From: monanxiao Date: Fri, 17 Mar 2023 18:02:22 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E6=98=B5=E7=A7=B0=E3=80=81=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/repositories/wechat/WechatUserRepository.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/common/repositories/wechat/WechatUserRepository.php b/app/common/repositories/wechat/WechatUserRepository.php index 50b1c1d3..50bd0c33 100644 --- a/app/common/repositories/wechat/WechatUserRepository.php +++ b/app/common/repositories/wechat/WechatUserRepository.php @@ -125,8 +125,8 @@ class WechatUserRepository extends BaseRepository $wechatUser = $this->dao->routineIdByWechatUser($routineOpenid); return Db::transaction(function () use ($createUser, $routineInfo, $wechatUser) { if ($wechatUser) { - $routineInfo['nickname'] = $wechatUser['nickname']; - $routineInfo['headimgurl'] = $wechatUser['headimgurl']; + // $routineInfo['nickname'] = $wechatUser['nickname']; + // $routineInfo['headimgurl'] = $wechatUser['headimgurl']; $wechatUser->save($routineInfo); } else { $wechatUser = $this->dao->create($routineInfo); From 76dada9dbfdf5c4418ab9a1c20ba941be4f8fd66 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 18 Mar 2023 09:26:52 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E6=88=B7?= =?UTF-8?q?=E5=85=A5=E9=A9=BB=E5=95=86=E6=88=B7=E7=B1=BB=E5=9E=8B=E9=AA=8C?= =?UTF-8?q?=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/store/merchant/MerchantIntention.php | 15 ++++++++++++++- app/validate/api/MerchantIntentionValidate.php | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index e81b065b..b010941c 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -106,7 +106,20 @@ class MerchantIntention extends BaseController protected function checkParams() { - $data = $this->request->params(['phone', 'mer_name', 'name', 'code', 'images', 'merchant_category_id', 'mer_type_id','area_id','street_id','village_id','is_nmsc']); + $data = $this->request->params([ + 'phone', + 'mer_name', + 'name', + 'code', + 'images', + 'merchant_category_id', + 'mer_type_id', + 'area_id', + 'street_id', + 'village_id', + 'is_nmsc' + ]); + app()->make(MerchantIntentionValidate::class)->check($data); $check = app()->make(SmsService::class)->checkSmsCode($data['phone'], $data['code'], 'intention'); $data['mer_type_id'] = (int)$data['mer_type_id']; diff --git a/app/validate/api/MerchantIntentionValidate.php b/app/validate/api/MerchantIntentionValidate.php index e3d1e81d..eddcc03d 100644 --- a/app/validate/api/MerchantIntentionValidate.php +++ b/app/validate/api/MerchantIntentionValidate.php @@ -24,7 +24,7 @@ class MerchantIntentionValidate extends Validate 'name|姓名' => 'require', 'mer_name|姓名' => 'require|max:32', 'merchant_category_id|商户分类' => 'require', - 'mer_type_id|店铺类型' => 'integer', + 'mer_type_id|店铺类型' => 'require|integer', 'code|验证码' => 'require', 'images|资质' => 'array', ]; From 12cfc15482e1a76185ce35b43aa5f98531d1cd21 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 18 Mar 2023 14:08:40 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=88=97=E8=A1=A8=EF=BC=8C=E5=BE=85=E8=AF=84=E4=BB=B7=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/repositories/store/order/StoreOrderRepository.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 5c40310c..dd5a5305 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -564,7 +564,10 @@ class StoreOrderRepository extends BaseRepository ->count(); $noDeliver = $this->dao->search(['uid' => $uid, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); - $noComment = $this->dao->search(['uid' => $uid, 'status' => 2, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); + $noComment = $this->dao->search(['uid' => $uid, 'status' => 2, 'paid' => 1]) + ->where('source', $source) + ->where('StoreOrder.is_del', 0) + ->count(); $done = $this->dao->search(['uid' => $uid, 'status' => 3, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); $refund = app()->make(StoreRefundOrderRepository::class)->getWhereCount(['uid' => $uid, 'status' => [0, 1, 2]]); $orderPrice = $this->dao->search(['uid' => $uid, 'paid' => 1])->where('source', $source)->sum('pay_price'); From 7d79a065177e5492ca0c7095cfd236138b4b8678 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 18 Mar 2023 16:37:54 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E3=80=81=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=AD=89=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/Auth.php | 119 +++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 43 deletions(-) diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index a36364bd..89daa31a 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -157,10 +157,13 @@ class Auth extends BaseController $data['extension_status'] = systemConfig('extension_status'); if (systemConfig('member_status')) $data['member_icon'] = $this->request->userInfo()->member->brokerage_icon ?? ''; if ($data['is_svip'] == 3) $data['svip_endtime'] = date('Y-m-d H:i:s',strtotime("+100 year")); - $find=Db::name('nk_user')->where('user_id',$user['uid'])->find(); - $data['no_update']=1; + + $find = Db::name('user')->find($user['uid']); + + $data['no_update'] = 1; + if ($find){ - $msg=Db::connect('nongke')->table('fa_szxc_information_usermsg')->where('user_id',$find['n_user_id'])->find(); + $msg = Db::connect('nongke')->table('fa_szxc_information_usermsg')->where('user_id', $user['uid'])->find(); if ($msg){ $data['no_update']=0; } @@ -168,10 +171,13 @@ class Auth extends BaseController }else{ $data['group_id']=1; } -// 新增返回商户后台登录地址 + + // 新增返回商户后台登录地址 $data['merchant_login'] = $this->request->domain().'/merchant'; -// 判断是否是商户,并且有没有完善信息 + + // 判断是否是商户,并且有没有完善信息 $mer_arr = Db::name('merchant_intention')->alias('a')->join('merchant b','a.mer_id=b.mer_id')->where('a.uid',$data['uid'])->where('a.is_del',0)->where('a.status',1)->field('b.mer_avatar,b.mer_banner,b.mer_info,b.service_phone,b.mer_address')->find(); + if($mer_arr){ if (!$mer_arr['mer_avatar'] || !$mer_arr['mer_banner'] || !$mer_arr['mer_info'] || !$mer_arr['service_phone'] || !$mer_arr['mer_address']) { $data['is_wsxx'] = 0; @@ -181,6 +187,7 @@ class Auth extends BaseController }else{ $data['is_wsxx'] = 0; } + return app('json')->success($data); } @@ -374,56 +381,82 @@ class Auth extends BaseController // if (!$sms_code) return app('json')->fail('验证码不正确'); $user = $repository->accountByUser($data['phone']); $auth = $this->parseAuthToken($data['auth_token']); + Db::startTrans(); try { if (!$user) { + $user = $repository->registr($data['phone'], null, $data['user_type']); - $msg = Db::connect('nongke')->table('fa_szxc_information_usermsg')->where('phone', $data['phone'])->find(); + + // 获取当前用户是否已经录入信息 + $msg = Db::connect('nongke') + ->table('fa_szxc_information_usermsg') + ->where('phone', $data['phone']) + ->find(); + + // 如果已经存在信息 if ($msg) { - $nk_user = Db::name('nk_user')->where('n_user_id', $msg['user_id'])->find(); - $users = Db::connect('nongke')->table('fa_user')->where('id', $msg['user_id'])->find(); - if (!$nk_user) { - $datas = [ - 'user_id' => $user['uid'], - 'n_user_id' => $msg['user_id'], - 'group_id' => $users['group_id'] - ]; - Db::name('nk_user')->insert($datas); - } else { - Db::name('user')->where('uid',$user['uid'])->update(['nickname'=>$msg['name']]); - Db::name('nk_user')->where('id', $nk_user['id'])->update(['user_id' => $user['uid'], 'group_id' => $users['group_id']]); - } - } else { - $time = time(); - $user_data = [ - 'openid' => 'wx' . $time, - 'group_id' => 1, - 'username' => 'wx' . $time, - 'nickname' => '微信用户' . $time, - 'avatar' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230111/58c84995456bc63b2660d9526f7062fc.png', - 'level' => 1, - 'prevtime' => $time, - 'jointime' => $time, - 'createtime' => $time, - 'updatetime' => $time, - 'status' => 'normal', - 'mobile' => $data['phone'], - ]; - $n_user_id = Db::connect('nongke')->table('fa_user')->insertGetId($user_data); - $datas = [ - 'user_id' => $user['uid'], - 'n_user_id' => $n_user_id, - 'group_id' => 1 - ]; - Db::name('nk_user')->insert($datas); - } + + // 假如已被录入过信息,那么就更新用户的user_id,绑定用户信息 + $msg = Db::connect('nongke') + ->table('fa_szxc_information_usermsg') + ->where('phone', $data['phone']) + ->update([ + 'user_id' => $user['uid'] + ]); + + // $nk_user = Db::name('nk_user')->where('n_user_id', $msg['user_id'])->find(); // -- 不需要写入农科用户表,所以暂时去除 + // $users = Db::connect('nongke')->table('fa_user')->where('id', $msg['user_id'])->find();// -- 不需要写入农科用户表,所以暂时去除 + + // -- 不需要写入农科用户表,所以暂时去除 + // if (!$nk_user) { + // $datas = [ + // 'user_id' => $user['uid'], + // 'n_user_id' => $msg['user_id'], + // 'group_id' => $users['group_id'] + // ]; + // Db::name('nk_user')->insert($datas); + // } else { + // Db::name('user')->where('uid',$user['uid'])->update(['nickname'=>$msg['name']]); + // Db::name('nk_user')->where('id', $nk_user['id'])->update(['user_id' => $user['uid'], 'group_id' => $users['group_id']]); + // } + + } + // else { // 假如存在用户的操作-- 不需要写入农科用户表,所以暂时去除 + + // $time = time(); + // $user_data = [ + // 'openid' => 'wx' . $time, + // 'group_id' => 1, + // 'username' => 'wx' . $time, + // 'nickname' => '微信用户' . $time, + // 'avatar' => 'https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230111/58c84995456bc63b2660d9526f7062fc.png', + // 'level' => 1, + // 'prevtime' => $time, + // 'jointime' => $time, + // 'createtime' => $time, + // 'updatetime' => $time, + // 'status' => 'normal', + // 'mobile' => $data['phone'], + // ]; + // $n_user_id = Db::connect('nongke')->table('fa_user')->insertGetId($user_data); + // $datas = [ + // 'user_id' => $user['uid'], + // 'n_user_id' => $n_user_id, + // 'group_id' => 1 + // ]; + // Db::name('nk_user')->insert($datas); + + // } } + Db::commit(); } catch (\Exception $e) { // 回滚事务 Db::rollback(); return app('json')->error($e->getMessage()); } + if ($auth && !$user['wechat_user_id']){ $repository->syncBaseAuth($auth, $user); } From 943fbd65f3391eea1ae44b5af8abceec7bfe7ea4 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Sat, 18 Mar 2023 17:36:19 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E9=93=BE=E4=BD=A3?= =?UTF-8?q?=E9=87=91=E5=88=86=E4=BD=A3=EF=BC=8C=E5=A2=9E=E5=8A=A0=E5=8C=BA?= =?UTF-8?q?=E9=95=87=E7=AD=89=E5=88=86=E4=BD=A3=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/jobs/SupplyChainOrderBrokerAgeJob.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php b/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php index 86833cfc..2dea7759 100644 --- a/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php +++ b/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php @@ -59,6 +59,7 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface 'supply_sn' => $data['order_sn'], // 订单编号 'order_id' => $data['order_id'], // 订单ID 'mer_id' => $data['mer_id'], // 商户ID + 'status' => 1, 'supply_level_id' => $supplyLevel['id'], // 分佣等级ID 'brokerage_price' => $usrPrice, // 获取的佣金金额 'user_info' => $user['nickname'], // 用户名 @@ -123,8 +124,8 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface 'brokerage_rate' => $v['level']['rate'] // 分佣比例 ]; - // 储存小组服务分佣记录 - SupplyChainBorkerage::create($dataArr); + SupplyChainBorkerage::create($dataArr); // 储存小组服务分佣记录 + SupplyChainTeam::inc('free_brokerage', $usrPrice)->update(); // 增加冻结佣金 } } } From c373bc035c31d97a3163b8c0dbbfe3814b4e58c2 Mon Sep 17 00:00:00 2001 From: monanxiao Date: Mon, 20 Mar 2023 14:55:36 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E9=93=BE=E5=85=A8=E9=83=A8=E5=88=86=E4=BD=A3=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crmeb/jobs/SupplyChainOrderBrokerAgeJob.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php b/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php index 2dea7759..f57b5732 100644 --- a/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php +++ b/crmeb/jobs/SupplyChainOrderBrokerAgeJob.php @@ -43,7 +43,7 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface $supplyTeamId = SupplyChainLinkMerchant::where('eb_merchant_id', $data['mer_id'])->value('fa_supply_chain_id'); // 获取供应链团队ID $supplyLevel = SupplyChainLevel::find($supplyTeam['supply_level_id']); // 获取供应链等级 $price = $data['brokerage_price']; // 待分润金额 == 订单佣金金额 - + // 判断 存在数据的话,进行分润 if($supplyTeam) { @@ -87,18 +87,20 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface // 增加小组服务佣金 $userRepository->incSupplyBrokerage($data['uid'], $price); - - // 后台分组用户开始 $userInfo = User::with('nkUserMsg')->find($data['uid']); // 当前用户信息 $nkUserMsg = $userInfo['nkUserMsg']; // 当前用户关联上级街道、区县等信息 - // $brigade_id = $nkUserMsg['brigade_id']; // 大队 + + $brigade_id = $nkUserMsg['brigade_id']; // 大队 $village_id = $nkUserMsg['village_id']; // 村 $street_id = $nkUserMsg['street_id']; //镇 $area_id = $nkUserMsg['area_id']; // 区域 $city_code = GeoArea::where('area_code', $area_id)->value('city_code'); // 市 - $supplyChainTeam = SupplyChainTeam::with('level')->whereIn('parent_code', [$village_id, $street_id, $area_id, $city_code]) + + // 获取供应链团队 + $supplyChainTeam = SupplyChainTeam::with('level') + ->where('parent_code', 'in', [$brigade_id, $village_id, $street_id, $area_id, $city_code]) ->select(); // 获取关联上级团队 if($supplyChainTeam) @@ -111,7 +113,7 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface // 分润数据 $dataArr = [ - 'supply_team_id' => $v['id'], // 用户ID + 'supply_team_id' => $v['id'], // 团队ID 'pay_price' => $data['inc'], // 订单金额 'price' => $price, // 订单分佣金额 'order_sn' => $data['order_sn'], // 订单编号 @@ -125,7 +127,7 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface ]; SupplyChainBorkerage::create($dataArr); // 储存小组服务分佣记录 - SupplyChainTeam::inc('free_brokerage', $usrPrice)->update(); // 增加冻结佣金 + SupplyChainTeam::where('id', $v['id'])->inc('free_brokerage', $usrPrice)->update(); // 增加冻结佣金 } } } From cdd6148f3f24a7bb2b66a545188b1fce81e73ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BD=AD=E6=A1=83?= <1098598843@qq.com> Date: Mon, 20 Mar 2023 16:59:20 +0800 Subject: [PATCH 7/7] 1 --- .../repositories/system/merchant/MerchantRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 8a40eab0..155b92a4 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -254,9 +254,9 @@ class MerchantRepository extends BaseRepository $merchant = $this->dao->create($data); $make->createMerchantAccount($merchant, $account, $password); $address_id = Db::name('merchant_address')->insertGetId(['mer_id'=>$merchant->mer_id,'street_id'=>$data['geo_street']]); - if($data['area_id'] && $data['village_id']){ - Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]); - } +// if($data['area_id'] && $data['village_id']){ +// Db::name('merchant_address')->where('id',$address_id)->update(['area_id'=>$data['area_id'],'village_id'=>$data['village_id']]); +// } app()->make(ShippingTemplateRepository::class)->createDefault($merchant->mer_id); app()->make(ProductCopyRepository::class)->defaulCopyNum($merchant->mer_id); return $merchant;