diff --git a/app/admin/lists/store_product/StoreProductLists.php b/app/admin/lists/store_product/StoreProductLists.php index a32f501f..7c0c9836 100644 --- a/app/admin/lists/store_product/StoreProductLists.php +++ b/app/admin/lists/store_product/StoreProductLists.php @@ -46,7 +46,7 @@ class StoreProductLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { return StoreProduct::where($this->searchWhere) - ->field(['id', 'image', 'store_name', 'cate_id', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) + ->field(['id', 'image', 'store_name','swap', 'cate_id', 'price','vip_price','sales', 'stock', 'is_show', 'unit', 'cost','rose','purchase','bar_code']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($item) { diff --git a/app/admin/logic/store_product/StoreProductLogic.php b/app/admin/logic/store_product/StoreProductLogic.php index 24e69d27..e88207b5 100644 --- a/app/admin/logic/store_product/StoreProductLogic.php +++ b/app/admin/logic/store_product/StoreProductLogic.php @@ -192,15 +192,15 @@ class StoreProductLogic extends BaseLogic self::cate_update($cate_id, $two['id'], $store_id, 3); self::cate_update($two['id'], $two['pid'], $store_id, 2); self::cate_update($two['pid'], 0, $store_id, 1); + }else{ + if ($one['pid'] == 0) { + self::cate_update($one['id'], 0, $store_id, 1); + } else { + self::cate_update($one['id'], $one['pid'], $store_id, 2); + self::cate_update($one['pid'], 0, $store_id, 1); + } } - } else { - if ($one['pid'] == 0) { - self::cate_update($one['id'], 0, $store_id, 1); - } else { - self::cate_update($one['id'], $one['pid'], $store_id, 2); - self::cate_update($one['pid'], 0, $store_id, 1); - } - } + } } } diff --git a/app/admin/logic/user/UserLogic.php b/app/admin/logic/user/UserLogic.php index ebc8d301..a88acd7f 100644 --- a/app/admin/logic/user/UserLogic.php +++ b/app/admin/logic/user/UserLogic.php @@ -68,7 +68,7 @@ class UserLogic extends BaseLogic public static function StoreAdd(array $params) { $passwordSalt = Config::get('project.unique_identification'); - $password = create_password($params['password'], $passwordSalt); + $password = create_password(123456, $passwordSalt); $defaultAvatar = config('project.default_image.admin_avatar'); $avatar = !empty($params['avatar']) ? FileService::setFileUrl($params['avatar']) : $defaultAvatar; @@ -81,7 +81,8 @@ class UserLogic extends BaseLogic 'account' => $params['mobile'], 'password' => $password, 'mobile' => $params['mobile'], - 'user_money' => $params['user_money'] + 'user_ship' => $params['user_ship'], + ]; $res=User::create($data); UserAddress::create([ @@ -90,17 +91,17 @@ class UserLogic extends BaseLogic 'mobile' => $params['mobile'], 'province' => $params['province'], 'city' => $params['city'], - 'district' => $params['district'], + 'area' => $params['area'], 'street' => $params['street'], 'village' => $params['village'], 'brigade' => $params['brigade'], 'is_default' => 1, ]); - Db::commit(); return $res; } catch (\Exception $e) { Db::rollback(); + d($e); self::setError($e->getMessage()); return false; } diff --git a/app/admin/validate/user/UserValidate.php b/app/admin/validate/user/UserValidate.php index 43df446b..8729791c 100644 --- a/app/admin/validate/user/UserValidate.php +++ b/app/admin/validate/user/UserValidate.php @@ -30,7 +30,7 @@ class UserValidate extends BaseValidate 'user_money' => 'float', 'province' => 'require', 'city' => 'require', - 'district' => 'require', + 'area' => 'require', 'street' => 'require', 'village' => 'require', 'brigade' => 'require', @@ -54,7 +54,7 @@ class UserValidate extends BaseValidate 'user_money' => '用户余额', 'province' => '省', 'city' => '市', - 'district' => '区', + 'area' => '区', 'street' => '街道', 'village' => '村', 'brigade' => ' 队', diff --git a/app/api/controller/IndexController.php b/app/api/controller/IndexController.php index 2f10d444..d3a68089 100644 --- a/app/api/controller/IndexController.php +++ b/app/api/controller/IndexController.php @@ -26,10 +26,11 @@ class IndexController extends BaseApiController public function index() { - $arr = StoreBranchProduct::where('store_id', 5)->select(); + $arr = StoreBranchProduct::select(); foreach ($arr as $item) { - StoreProductLogic::updateGoodsclass($item['cate_id'], 5); + StoreProductLogic::updateGoodsclass($item['cate_id'], $item['store_id']); } + d(1); try { $wechat = new PayService(1); $time = time(); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 57381099..4f2f0c77 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -298,15 +298,41 @@ class PayNotifyLogic extends BaseLogic } $fees = bcdiv(bcmul($order['pay_price'], '0.01', 2), 1, 2); $count_frees=bcadd($count_frees,bcmul($fees,3,2),2); - - $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + $village_uid=0; + $brigade_uid=0; + //查询用户对应的村长和队长 + if($order['uid']>0){ + $address=UserAddress::where(['uid'=>$order['uid'],'is_default'=>1])->find(); + if($address){ + $arr1=UserAddress::where(['village'=>$address['village'],'is_default'=>1])->column('uid'); + if($arr1){ + $village_uid=User::where('id','in',$arr1)->where('user_ship',2)->value('id'); + } + $arr2=UserAddress::where(['village'=>$address['village'],'brigade'=>$address['brigade'],'is_default'=>1])->column('uid'); + if($arr2){ + $brigade_uid=User::where('id','in',$arr1)->where('user_ship',3)->value('id'); + } + } + } + //村长获得 + if($village_uid>0){ + $financeLogic->other_arr['vip_uid'] = $village_uid; + } + $financeLogic->in($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, OrderEnum::VILLAGE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + //队长获得 + if($brigade_uid>0){ + $financeLogic->other_arr['vip_uid'] = $brigade_uid; + } + $financeLogic->in($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, OrderEnum::BRIGADE_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); - $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + //其他获得 + $financeLogic->other_arr['vip_uid']=0; + $financeLogic->in($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $fees, OrderEnum::OTHER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); } - $financeLogic->in($transaction_id, $count_frees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); //vip订单获得 + //供应链订单获得 + $financeLogic->in($transaction_id, $count_frees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, $order['pay_type']); $financeLogic->out($transaction_id, $count_frees, OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); // } $financeLogic->save(); diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index dfcf265a..c2ad88d5 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -49,7 +49,7 @@ class StoreFinanceFlowLogic extends BaseLogic if (empty($this->financeSn)) { $this->financeSn = $this->getSn(); } - $this->list[] = [ + $data=[ 'order_id' => $this->order['id'], 'transaction_id' => $transaction_id, 'order_sn' => $this->order['order_id'], @@ -65,6 +65,23 @@ class StoreFinanceFlowLogic extends BaseLogic 'financial_record_sn' => $this->financeSn . ($this->index++), 'create_time'=>time() ]; + switch($financialType){ + case OrderEnum::MERCHANT_ORDER_OBTAINS: // 商户 + case OrderEnum::ORDER_MARGIN: // 商户保证金 + $data['type'] =OrderEnum::MERCHANT; + break; + case OrderEnum::PLATFORM_ORDER_OBTAINS: // 平台 + case OrderEnum::ORDER_HANDLING_FEES: // 手续费 + $data['type'] =OrderEnum::PLATFORM; + break; + case OrderEnum::SUPPLIER_ORDER_OBTAINS: // 供应链 + $data['type'] =OrderEnum::SUPPLIER; + break; + default: // 用户 + $data['type'] =OrderEnum::USER; + break; + } + $this->list[] = $data; } public function save() diff --git a/app/store/controller/user/UserController.php b/app/store/controller/user/UserController.php index 547f4f36..4a608385 100644 --- a/app/store/controller/user/UserController.php +++ b/app/store/controller/user/UserController.php @@ -22,12 +22,12 @@ class UserController extends BaseAdminController public function add() { $params = (new UserValidate())->post()->goCheck('storeAdd'); - d($params); $result = UserLogic::StoreAdd($params); - if (true === $result) { - return $this->success('添加成功', [], 1, 1); + if (UserLogic::hasError() ) { + return $this->fail(UserLogic::getError()); } - return $this->fail(UserLogic::getError()); + return $this->success('添加成功', [], 1, 1); + } diff --git a/app/store/lists/user/UserLists.php b/app/store/lists/user/UserLists.php index 379d078f..1d456395 100644 --- a/app/store/lists/user/UserLists.php +++ b/app/store/lists/user/UserLists.php @@ -6,6 +6,7 @@ namespace app\store\lists\user; use app\store\lists\BaseAdminDataLists; use app\common\model\user\User; +use app\common\model\user\UserShip; class UserLists extends BaseAdminDataLists { @@ -34,7 +35,7 @@ class UserLists extends BaseAdminDataLists public function lists(): array { - $field = "id,nickname,real_name,sex,avatar,account,mobile,user_money,create_time"; + $field = "id,nickname,real_name,sex,avatar,account,mobile,user_money,user_ship,create_time"; $lists = User::where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->field($field) @@ -42,6 +43,7 @@ class UserLists extends BaseAdminDataLists ->select()->each(function($data){ $data['sex_text'] = $data->sex_text; $data['mobile'] = substr_replace($data['mobile'], '****', 3, 4); + $data['user_ship_name'] =$data['user_ship']==0?'一般用户':UserShip::where('id',$data['user_ship'])->value('title'); })->toArray(); return $lists; }