diff --git a/app/command/brand.php b/app/command/brand.php index 83c1ac1..e95d9ee 100644 --- a/app/command/brand.php +++ b/app/command/brand.php @@ -77,7 +77,9 @@ class brand extends Command //全网品宣贡献值之和 $allBrandValue = userModel::getDB()->where('status', 1)->sum('brand_integral'); - + if ($allBrandValue <= 0) { + die; + } Db::startTrans(); foreach ($userList as $k => $v) { try { @@ -94,20 +96,15 @@ class brand extends Command ]); //用户总贡献值 = 当前总贡献值+昨日的品宣贡献值 $all_value = $brandGongxian + $v['all_value']; - //贡献值自动转换为超级积分 暂定1:1 -// $superBrand = $all_value; - //超级积分自动转换为增值积分 按照每天的比例 这个是重点 -// $brandAdd = $superBrand; - $user = userModel::getDB()->where('uid', $v['uid'])->find(); -// //品宣积分清0 -// $user->brand_integral = 0; - //总贡献清0 - $user->all_value = $all_value; -// //更新增值积分 -// $user->brand_add += $brandAdd; - //天数+1 - $user->super_days += 1; - $user->save(); + + $growth_num = bcdiv($all_value, $v['growth_rate'], 2); + userModel::getDB() + ->where('uid', $v['uid']) + ->update([ + 'brand_integral' => 0, + 'all_value' => 0, + 'brokerage_price' => $growth_num + ]); Db::commit(); } catch (\Exception $exception) { diff --git a/app/common/model/user/UserPre.php b/app/common/model/user/UserPre.php new file mode 100644 index 0000000..f5893cb --- /dev/null +++ b/app/common/model/user/UserPre.php @@ -0,0 +1,43 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\user; + + +use app\common\model\BaseModel; +use app\common\repositories\store\CityAreaRepository; + +class UserPre extends BaseModel +{ + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tablePk(): string + { + return 'id'; + } + + /** + * @return string + * @author xaboy + * @day 2020-03-30 + */ + public static function tableName(): string + { + return 'user_pre'; + } + +} diff --git a/app/common/repositories/store/product/ProductLabelRepository.php b/app/common/repositories/store/product/ProductLabelRepository.php index 58d5530..fe32e5b 100644 --- a/app/common/repositories/store/product/ProductLabelRepository.php +++ b/app/common/repositories/store/product/ProductLabelRepository.php @@ -104,7 +104,7 @@ class ProductLabelRepository extends BaseRepository if (!is_array($data)) $data = explode(',', $data); foreach ($data as $item) { $data = $this->dao->getSearch(['product_label_id' => $item,'mer_id' => $merId])->find(); - if (!$data) throw new ValidateException( '标签ID:'.$item.',不存在'); +// if (!$data) throw new ValidateException( '标签ID:'.$item.',不存在'); } } return true; diff --git a/app/controller/api/user/User.php b/app/controller/api/user/User.php index f09d3aa..38fdec0 100644 --- a/app/controller/api/user/User.php +++ b/app/controller/api/user/User.php @@ -14,6 +14,7 @@ namespace app\controller\api\user; +use AlibabaCloud\SDK\Dysmsapi\V20170525\Models\AddShortUrlResponseBody\data; use app\common\repositories\store\IntegralRepository; use app\common\repositories\store\service\StoreServiceRepository; use app\common\repositories\system\CacheRepository; @@ -21,6 +22,7 @@ use app\common\repositories\user\MemberinterestsRepository; use app\common\repositories\user\UserBillRepository; use app\common\repositories\user\UserBrokerageRepository; use app\common\model\user\ValueContributionLog; +use app\common\model\user\UserPre; use app\common\model\store\product\Product; use app\common\model\user\CashLog; use app\common\repositories\user\UserRepository; @@ -368,6 +370,21 @@ class User extends BaseController return app('json')->success('分享成功'); } + public function preSuply() + { + $produceid = $this->request->param('id'); + $num = $this->request->param('num'); + $merid = Product::getDB()->where('product_id', $produceid)->find()->mer_id; + + UserPre::getDB()->insert([ + 'uid' => $this->user->uid, + 'num' => $num, + 'mer_id' => $merid, + 'ctime' => date('Y-m-d H:i:s'), + ]); + return app('json')->success('成功'); + } + //获取用户积分/贡献值明细变动 public function getBrandList() { diff --git a/app/controller/merchant/user/UserMerchant.php b/app/controller/merchant/user/UserMerchant.php index ce80d5d..86b33e2 100644 --- a/app/controller/merchant/user/UserMerchant.php +++ b/app/controller/merchant/user/UserMerchant.php @@ -16,6 +16,8 @@ namespace app\controller\merchant\user; use app\common\repositories\store\coupon\StoreCouponUserRepository; use app\common\repositories\store\order\StoreOrderRepository; +use app\common\model\user\UserPre; +use app\common\model\user\User as userModel; use app\common\repositories\user\UserLabelRepository; use app\common\repositories\user\UserMerchantRepository; use crmeb\basic\BaseController; @@ -62,6 +64,27 @@ class UserMerchant extends BaseController return app('json')->success($this->repository->getList($where, $page, $limit)); } + public function getList2() + { + + $list = UserPre::getDB()->where('status', 0)->where('mer_id', $this->request->merId())->select()->toArray(); + foreach ($list as &$v) { + $v['nickname'] = userModel::getDB()->where('uid', $v['uid'])->find()->nickname; + } + return app('json')->success($list); + + } + + + public function getList3() + { + $where = $this->request->params(['id', 'status']); + + $list = UserPre::getDB()->where('id', $where['id'])->update(['status' => $where['status']]); + + return app('json')->success(''); + + } /** * @param $id diff --git a/route/api.php b/route/api.php index be7f16c..dbdf524 100644 --- a/route/api.php +++ b/route/api.php @@ -110,6 +110,7 @@ Route::group('api/', function () { //wmc //分享视频/推文增加品宣积分 Route::get('brand', 'User/brand'); + Route::get('preSuply', 'User/preSuply'); Route::get('getBrandList', 'User/getBrandList'); Route::get('getPayConfig', 'User/getPayConfig'); Route::get('cashWithdrawal', 'User/cashWithdrawal'); diff --git a/route/merchant/users.php b/route/merchant/users.php index b307b2f..5a71da7 100644 --- a/route/merchant/users.php +++ b/route/merchant/users.php @@ -28,6 +28,12 @@ Route::group(function () { Route::get('lst', '/getList')->name('merchantUserLst')->option([ '_alias' => '列表', ]); + Route::get('lst2', '/getList2')->name('merchantUserLst2')->option([ + '_alias' => '列表', + ]); + Route::get('lst3', '/getList3')->name('merchantUserLst3')->option([ + '_alias' => '列表', + ]); //修改用户标签 Route::get('change_label/form/:id', '/changeLabelForm')->name('merchantUserChangeLabelForm')->option([ '_alias' => '修改标签表单',