Merge remote-tracking branch 'origin/master'
# Conflicts: # app/common/repositories/wechat/WechatUserRepository.php # app/controller/api/Auth.php
This commit is contained in:
commit
00c898ba58
@ -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');
|
||||
|
@ -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;
|
||||
|
@ -125,6 +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'];
|
||||
$wechatUser->save($routineInfo);
|
||||
} else {
|
||||
$wechatUser = $this->dao->create($routineInfo);
|
||||
|
@ -157,14 +157,20 @@ 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"));
|
||||
$data['no_update']=1;
|
||||
$data['group_id']=1;
|
||||
$msg=Db::connect('nongke')->table('fa_szxc_information_usermsg')->where('user_id',$this->request->userInfo()->uid)->find();
|
||||
|
||||
$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', $user['uid'])->find();
|
||||
if ($msg){
|
||||
$data['no_update']=0;
|
||||
$data['group_id']=$this->request->userInfo()->group_id;
|
||||
}
|
||||
// 新增返回商户后台登录地址
|
||||
$data['group_id']=$find['group_id'];
|
||||
}
|
||||
|
||||
// 新增返回商户后台登录地址
|
||||
$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();
|
||||
@ -219,6 +225,7 @@ class Auth extends BaseController
|
||||
}
|
||||
/** @var WechatUserRepository $make */
|
||||
$make = app()->make(WechatUserRepository::class);
|
||||
|
||||
$user = $make->syncUser($wechatInfo['openid'], $wechatInfo);
|
||||
if (!$user)
|
||||
return app('json')->fail('授权失败[003]');
|
||||
@ -373,6 +380,24 @@ class Auth extends BaseController
|
||||
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();
|
||||
|
||||
// 如果已经存在信息
|
||||
if ($msg) {
|
||||
|
||||
// 假如已被录入过信息,那么就更新用户的user_id,绑定用户信息
|
||||
$msg = Db::connect('nongke')
|
||||
->table('fa_szxc_information_usermsg')
|
||||
->where('phone', $data['phone'])
|
||||
->update([
|
||||
'user_id' => $user['uid']
|
||||
]);
|
||||
}
|
||||
}
|
||||
Db::commit();
|
||||
} catch (\Exception $e) {
|
||||
@ -499,6 +524,7 @@ class Auth extends BaseController
|
||||
if (!isset($userInfo['openId'])) $userInfo['openId'] = $userInfoCong['openid'] ?? '';
|
||||
$userInfo['unionId'] = $userInfoCong['unionid'] ?? $userInfo['unionId'] ?? '';
|
||||
if (!$userInfo['openId']) throw new ValidateException('openid获取失败');
|
||||
|
||||
/** @var WechatUserRepository $make */
|
||||
$make = app()->make(WechatUserRepository::class);
|
||||
$user = $make->syncRoutineUser($userInfo['openId'], $userInfo, $createUser);
|
||||
@ -581,12 +607,17 @@ class Auth extends BaseController
|
||||
if ($auth['auth']['spread'] ?? 0) {
|
||||
$userRepository->bindSpread($user, (int)($auth['auth']['spread']));
|
||||
}
|
||||
$uid = Db::name('user')->where('wechat_user_id',$authInfo['wechat_user_id'])->value('uid');
|
||||
$find=Db::name('nk_user')->where('user_id',$uid)->find();
|
||||
$user['no_update']=1;
|
||||
$user['group_ids'] = $user['group_id'];
|
||||
$msg=Db::connect('nongke')->table('fa_szxc_information_usermsg')->where('user_id',$user['uid'])->cache(true)->find();
|
||||
$user['group_ids'] = 1;
|
||||
if ($find && $find['n_user_id']!=0){
|
||||
$user['group_ids'] = $find['group_id'];
|
||||
$msg=Db::connect('nongke')->table('fa_szxc_information_usermsg')->where('user_id',$find['n_user_id'])->cache(true)->find();
|
||||
if ($msg){
|
||||
$user['no_update']=0;
|
||||
}
|
||||
}
|
||||
|
||||
$tokenInfo = $userRepository->createToken($user);
|
||||
$userRepository->loginAfter($user);
|
||||
|
@ -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'];
|
||||
|
@ -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',
|
||||
];
|
||||
|
@ -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)
|
||||
{
|
||||
@ -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'], // 用户名
|
||||
@ -86,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)
|
||||
@ -110,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'], // 订单编号
|
||||
@ -123,8 +126,8 @@ class SupplyChainOrderBrokerAgeJob implements JobInterface
|
||||
'brokerage_rate' => $v['level']['rate'] // 分佣比例
|
||||
];
|
||||
|
||||
// 储存小组服务分佣记录
|
||||
SupplyChainBorkerage::create($dataArr);
|
||||
SupplyChainBorkerage::create($dataArr); // 储存小组服务分佣记录
|
||||
SupplyChainTeam::where('id', $v['id'])->inc('free_brokerage', $usrPrice)->update(); // 增加冻结佣金
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user