Taskorderguquan.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * @package merchant
  4. * @Author: Qinii
  5. * @Date: 2020/5/28
  6. */
  7. namespace app\controller\api\store\merchant;
  8. use think\App;
  9. use crmeb\basic\BaseController;
  10. use app\common\repositories\system\merchant\MerchantRepository as repository;
  11. use think\facade\Db;
  12. use think\facade\Log;
  13. use function Symfony\Component\VarDumper\Dumper\esc;
  14. class Taskorderguquan extends BaseController
  15. {
  16. public function lst6()
  17. {
  18. return;
  19. // return;
  20. // $store_product_datas = Db::name('old_user_of_goods_old')->select();
  21. //$week_record = 45500 + 60000 + 1400;
  22. //$week_record = 23800 + 60000;//20250222
  23. // $week_record = 64400;//20250303
  24. }
  25. //添加复购金
  26. public function fugou_user_log($uid,$num,$order_id,$type_inc_des,$status=-1){
  27. $fugou_data = Db::name('user')->where("uid",$uid)->find();
  28. $bill = [
  29. 'uid'=>$uid,
  30. 'number'=>$num,//数量
  31. 'status'=>$status,//复购金状态1-有效 0-失效 -1待确认
  32. 'mark'=>"复购金",//备注
  33. 'desc'=>"10%作为复购金",//描述
  34. 'order_id'=>$order_id,//订单id
  35. 'surplus'=>0,//剩余
  36. 'order_type'=>11,//关联订单ID
  37. 'type'=>$type_inc_des,//复购金类型 :1赠送,2消耗
  38. 'settlement_time'=>date('Y-m-d H:i:s'),//添加时间,
  39. 'addtime'=>time(),
  40. ];
  41. Db::name('user_sign_fugou')->insert($bill);
  42. }
  43. //添加平台分佣2.0系统收益明细日志(养老金金额)
  44. public function bill_user_log111111($uid,$name,$num,$mark,$comm){
  45. $con_data = Db::name('user')->where("uid",$uid)->find();
  46. //如果是会员专区就即刻到账
  47. // Db::name('user')->where("uid",$con_data['uid'])->update(['brokerage_price'=> $con_data['brokerage_price'] + $num]);
  48. $bill = [
  49. 'uid'=>$uid,
  50. 'link_id'=>0,//关联订单id
  51. 'pm'=>1,//0:支出,1:获得
  52. 'title'=>$name,//账单标题
  53. 'category'=>'now_money',//明细种类
  54. 'type'=>'commission',//明细类型
  55. 'number'=>$num,//明细数字
  56. 'balance'=>0,//剩余
  57. 'mark'=>$mark,//备注
  58. 'create_time'=>date('Y-m-d H:i:s'),//添加时间
  59. 'status'=>1,//0待确定,1有效,-1无效
  60. 'commission_type'=>$comm,//佣金类型 1代理费 2 消费佣金 3直推奖√ 4辖区佣金\r\n5 养老金√ 6 广告费
  61. //7 跨店奖励√ 8平台奖励 9渠道商\r\n10 推荐创客收益√ 11分红奖金√ 12代理区域收益√ 13消费循环佣金
  62. //14-推荐代理收益√ 15邀请小区团长升级√ 16大v分享奖√ 17创客合伙人√ 18积分奖励√ 19创客补贴√’
  63. 'order_sn'=>0,//订单号
  64. 'tripartite'=>0,//
  65. 'type_shop'=>0,//0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上
  66. 'mer_id'=>0,//商户id
  67. 'source'=>0,//1线下 0线上
  68. 'order_type'=>1,//1自营 2 第三方 订单类型
  69. 'is_red_brokerage'=>0,//1红积分对冲佣金 0正常佣金
  70. 'gzc'=>3,//养老金是否已进入公证处log表0:未进入。1:已进入
  71. 'take_time'=>'',//结算时间
  72. 'district_id'=>'',//
  73. 'street_id'=>'',//
  74. 'month'=>'',//月份
  75. ];
  76. Db::name('user_bill')->insert($bill);
  77. }
  78. //发放佣金 示例: $this->change_user_log($v,'amount',1,$all_award,"member_award","星级分红入账"."-".$value['title']);//释放佣金
  79. function change_user_log($user_id,$type,$change_status,$money,$routine,$remark="",$is_admin=1,$appoint_money = 0)
  80. {
  81. $transition = [
  82. 'pv'=>1,
  83. "gb"=>2,
  84. "df"=>3,
  85. "vr"=>4,
  86. "bt"=>5,
  87. "withdraw_quota_old"=>6,//提现
  88. "unsettled_pension"=>7,
  89. "amount_old"=>8//发放佣金
  90. ];
  91. $routineInfo = Db::name("old_routine_log_of_key")->where("key",$routine)->find();
  92. if(empty($routineInfo)) {
  93. return false;
  94. }
  95. $key_id = isset($routineInfo['id']) ? $routineInfo['id'] : 0;
  96. if($appoint_money > 0) {
  97. $alter_money = $appoint_money;
  98. }else{
  99. //再去查询变更前的 金额
  100. $alter_money = Db::name("user")->where('uid',$user_id)->value($type);
  101. }
  102. if($change_status == 1) {
  103. //新增前
  104. $alter_money = $alter_money-$money;
  105. }else if($change_status == 2){
  106. //减少前
  107. $alter_money = $alter_money + $money;
  108. }
  109. if($alter_money < 0) {
  110. $alter_money =0;
  111. }
  112. $inser_data = [];
  113. $inser_data['user_id'] = $user_id;
  114. $inser_data['type'] = $transition[$type];
  115. $inser_data['change_status'] = $change_status;
  116. $inser_data['money'] = $money;
  117. $inser_data['routine_log_of_key_id'] = $key_id;
  118. $inser_data['remark'] = $remark;
  119. $inser_data['is_admin'] = $is_admin;
  120. $inser_data['create_time'] = time();
  121. $inser_data['alter_money'] = isset($alter_money) ? $alter_money : 0;
  122. Db::name("old_user_log")->insert($inser_data);
  123. }
  124. }