Просмотр исходного кода

选品删除&分润比例默认&选品图片调整

xialei 1 год назад
Родитель
Сommit
400eabc1af

+ 106 - 1
app/common/repositories/merchant/order/OrderMerchantRepository.php

@@ -1290,7 +1290,13 @@ class OrderMerchantRepository extends BaseRepository
1290 1290
         $mer_fanyongbili = merchantConfig($order['mer_id'], 'base_commission');
1291 1291
         //如果商户返佣比例设置的是0怎查系统设设置的分佣比例
1292 1292
         if ($mer_fanyongbili == 0) {
1293
-            $mer_fanyongbili = merchantConfig(0, 'extension_one_rate');
1293
+            Db::name('system_config_value')->insert([
1294
+                'config_key'  => 'base_commission',
1295
+                'value'       => (int)5,
1296
+                'mer_id'      => $order['mer_id'],
1297
+            ]);
1298
+            $mer_fanyongbili = 5;
1299
+            // $mer_fanyongbili = merchantConfig(0, 'extension_one_rate');
1294 1300
         }
1295 1301
         //如果系统设置的是0就不执行!
1296 1302
         if ($mer_fanyongbili == 0) {
@@ -1455,6 +1461,105 @@ class OrderMerchantRepository extends BaseRepository
1455 1461
 
1456 1462
 
1457 1463
 
1464
+    //商户二维码收款返佣-补发推荐人
1465
+    public function feidacang_fenyong_bufa($user, $order, $pay_status)
1466
+    {
1467
+        $userRepository = app()->make(UserRepository::class);
1468
+        if ($pay_status == 1) {
1469
+            return '';
1470
+        }
1471
+        $top_data = Db::name('user')->where('uid', $order['uid'])->field('spread_uid,mer_id')->find();
1472
+        $mer_fanyongbili = merchantConfig($order['mer_id'], 'base_commission');
1473
+        //如果商户返佣比例设置的是0怎查系统设设置的分佣比例
1474
+        if ($mer_fanyongbili == 0) {
1475
+            $mer_fanyongbili = merchantConfig(0, 'extension_one_rate');
1476
+        }
1477
+        //如果系统设置的是0就不执行!
1478
+        if ($mer_fanyongbili == 0) {
1479
+            Db::name('log')->insert(['data' => '订单号:' . $order['order_sn'] . ' 订单因商家、平台没有设置返佣比例无任何奖励特此记录!']);
1480
+            return '';
1481
+        }
1482
+        $order_sn = $order['order_sn'] ?? '';
1483
+        $order_id = $order['order_id'] ?? '';
1484
+        //可分总佣金
1485
+        $divisible_commission = bcmul($order['pay_price'], bcdiv($mer_fanyongbili, '100', 2), 2);//让利部分
1486
+        $pv = bcmul($divisible_commission, '0.7', 2);//商家让利部分30%给消费者做养老金,70%做业绩PV
1487
+
1488
+        /**
1489
+         * 各自的比例开始
1490
+         */
1491
+        //用户养老金比例30%
1492
+        $yonghu_bili = '0.3';
1493
+        //用户红包比例
1494
+        $yonghu_hongbao = '0.45';
1495
+        //用户推荐人养老金比例
1496
+        $yonghu_bili_tuijian = '0.05';
1497
+        //用户推荐人,消费者的推荐人佣金
1498
+        $yonghu_tuijian = $this->getUserGroupRate($user['user_group']);
1499
+        //用户推荐人,消费者的推荐人复购金
1500
+        $yonghu_fugou = '0.1';
1501
+        /**
1502
+         * 各自的比例结束
1503
+         */
1504
+
1505
+        // 用户推荐人---------------------------------------------------------------------------------------------------------------
1506
+
1507
+        //用户推荐人可拿的养老金
1508
+        $user_yanglaojin = bcmul($pv, $yonghu_bili_tuijian, 2);
1509
+        if ($user_yanglaojin >= 0.01) {
1510
+            $mark = "推荐人扫码消费获得养老金" . $user_yanglaojin;
1511
+            $title = "养老金";
1512
+            $source = 1;
1513
+            $commission_type = 5;
1514
+            $this->add_bill($title, $user_yanglaojin, $top_data["spread_uid"], $mark, $commission_type, $order_sn, $order_id, $order["mer_id"], $source, 1);
1515
+        } else {
1516
+            Db::name('log')->insert(['data' => '订单号:' . $order['order_sn'] . '付款额度较低或 商家、平台设置的返佣比例较低,养老金低于0.01无法入库 特此记录!']);
1517
+        }
1518
+
1519
+        //用户推荐人佣金
1520
+        $tuijian_yongjin = bcmul($pv, $yonghu_tuijian, 2);
1521
+        $tuijian_yongjin_90 = bcmul($tuijian_yongjin, '0.9', 2);
1522
+        if ($tuijian_yongjin_90 >= 0.01) {
1523
+            $mark = "推荐人扫码消费获得" . $tuijian_yongjin_90 . '佣金';
1524
+            $title = "佣金";
1525
+            $source = 1;
1526
+            $commission_type = 3;
1527
+            $this->add_bill($title, $tuijian_yongjin_90, $top_data["spread_uid"], $mark, $commission_type, $order_sn, $order_id, $order["mer_id"], $source, 1);
1528
+        } else {
1529
+            Db::name('log')->insert(['data' => '订单号:' . $order['order_sn'] . '付款额度较低或 商家、平台设置的返佣比例较低,佣金低于0.01无法入库 特此记录!']);
1530
+        }
1531
+
1532
+        //用户推荐人获得复购金佣金百分之10
1533
+        $tuijian_fugou = bcmul($tuijian_yongjin, $yonghu_fugou, 2);
1534
+        if ($tuijian_fugou >= 0.01) {
1535
+            $bill = [
1536
+                'uid'=>$top_data["spread_uid"],
1537
+                'number'=>$tuijian_fugou,//数量
1538
+                'status'=>1,//复购金状态1-有效 0-失效 -1待确认
1539
+                'mark'=>"推荐人扫码消费赠送" . $tuijian_fugou . '复购金',//备注
1540
+                'order_id'=>$order_id,//订单id
1541
+                'surplus'=>0,//剩余
1542
+                'order_type'=>0,//关联订单ID
1543
+                'type'=>1,//复购金类型 :1赠送,2消耗
1544
+                'settlement_time'=>date('Y-m-d H:i:s'),//添加时间,
1545
+                'addtime'=>time(),
1546
+            ];
1547
+            Db::name('user_sign_fugou')->insert($bill);
1548
+            $user_fugou = Db::name('user')->where('uid', $top_data["spread_uid"])->value('fugou');
1549
+            $user_fugou = bcadd($user_fugou, (float)$tuijian_fugou,2);
1550
+            Db::name('user')->where('uid', $top_data["spread_uid"])->update(['fugou'=>$user_fugou]);
1551
+        } else {
1552
+            Db::name('log')->insert(['data' => '订单号:' . $order['order_sn'] . '付款额度较低或 商家、平台设置的复购金比例较低,复购金低于0.01无法入库 特此记录!']);
1553
+        }
1554
+    }
1555
+
1556
+
1557
+
1558
+
1559
+
1560
+
1561
+
1562
+
1458 1563
 
1459 1564
 
1460 1565
     //商户二维码收款商家返佣

+ 8 - 0
app/common/repositories/store/product/ProductRepository.php

@@ -2030,6 +2030,14 @@ class ProductRepository extends BaseRepository
2030 2030
         return true;
2031 2031
     }
2032 2032
 
2033
+    // 供应链商品删除
2034
+    public function changeDelete($ids)
2035
+    {
2036
+        $data = ['is_show' => 0, 'is_del' =>1];
2037
+        $this->dao->update($ids, $data);
2038
+    }
2039
+
2040
+
2033 2041
     // 供应链商品上下架
2034 2042
     public function changeStatus($ids, $is_show)
2035 2043
     {

+ 2 - 0
app/controller/api/douhuomall/Take.php

@@ -60,6 +60,7 @@ class Take
60 60
                 //sku信息处理
61 61
                 $skuInfo = $goodsInfo['sku_list'];
62 62
                 foreach ($skuInfo as $k=>$v) {
63
+                    $skuInfo[$k]['img_url'] = $this->seveImg($value['goods_id'], $v['main_img'], $targetDir);//规格图片
63 64
                     $skuInfo[$k]['cost_price'] = bcadd($v['plat_price'], bcmul($v['plat_price'], 0.03, 2),2);//成本价格 原来进价的基础上加百分之3
64 65
                     $skuInfo[$k]['market_price'] = bcadd($skuInfo[$k]['cost_price'], bcmul($skuInfo[$k]['cost_price'], 0.2, 2),2);//销售价格  售价在成本价格的基础上加百分20
65 66
                     $skuInfo[$k]['profit'] = bcdiv($skuInfo[$k]['market_price'], $skuInfo[$k]['cost_price'], 2);
@@ -101,6 +102,7 @@ class Take
101 102
 
102 103
     public function seveImg($goods_id, $img_url, $targetDir)
103 104
     {
105
+        if(!$img_url) return $img_url;
104 106
         if (is_array($img_url)){
105 107
             $new_img_url = [];
106 108
             foreach ($img_url as $value) {

+ 8 - 0
app/controller/merchant/store/product/Product.php

@@ -86,6 +86,14 @@ class Product extends BaseController
86 86
         return app('json')->success("修改成功");
87 87
     }
88 88
 
89
+
90
+    // 供应链商品删除
91
+    public function deleteXp($id) {
92
+        if (empty($id)) return app('json')->fail('请选择商品');
93
+        $this->repository->changeDelete($id,);
94
+        return app('json')->success('删除成功');
95
+    }
96
+
89 97
     // 供应链商品上下架
90 98
     public function changeShow() {
91 99
         $is_show = $this->request->param('is_show', 0);

+ 13 - 9
app/controller/merchant/system/Merchant.php

@@ -220,8 +220,9 @@ class Merchant extends BaseController
220 220
         $merId = $this->request->merId();
221 221
         $data = Db::name('system_config_value')->where('config_key', $name)->where('mer_id', $merId)->value('value');
222 222
         if (!$data){
223
-            if ($name == 'shop_bonus_setting') {
224
-                return app('json')->success(['yanglao_rate' => 0, 'shop_bonus_rate' => 0]);
223
+            if ($name == 'base_commission') {
224
+                return app('json')->success(0);
225
+                // return app('json')->success(['yanglao_rate' => 0, 'shop_bonus_rate' => 0]);
225 226
             } else {
226 227
                 return app('json')->fail('配置不存在');
227 228
             }
@@ -246,16 +247,19 @@ class Merchant extends BaseController
246 247
         $value = input('value');
247 248
         if (!$name || !$value) return app('json')->fail('保存失败');
248 249
 
250
+        switch ($name){
251
+            case 'base_commission':
252
+                if ((int)$value < 5) {
253
+                    return app('json')->fail('商户让利比例最低5%');
254
+                }
255
+                if ((int)$value > 100) {
256
+                    return app('json')->fail('商户让利比例最高100%');
257
+                }
258
+                break;
259
+        }
249 260
 
250 261
         /** @var ConfigClassifyRepository $make */
251 262
         if (!in_array($name, ['base_commission'])) {
252
-            switch ($name){
253
-                case 'base_commission':
254
-                    if ((int)$value < 30) {
255
-                        return app('json')->fail('商户让利比例最低10%');
256
-                    }
257
-                    break;
258
-            }
259 263
             return app('json')->fail('只支持修改base_commission');
260 264
         }
261 265
         if(Db::name('system_config_value')->where('config_key', $name)->where('mer_id', $merId)->find()){

+ 1 - 0
route/merchant.php

@@ -387,6 +387,7 @@ Route::group(config('admin.api_merchant_prefix') . '/', function () {
387 387
             Route::get('gong_lst', '/gongProductLst')->name('gongStoreProductLst');
388 388
             Route::get('gong_lst_filter', '/getGongStatusFilter')->name('gongStoreProductLstFilter');
389 389
             Route::post('edit_price/:id', '/editPrice')->name('gongStoreProductEdit');
390
+            Route::post('delete_xp/:id', '/deleteXp')->name('gongStoreProductEdit');
390 391
             Route::post('change_show', '/changeShow')->name('gongStoreProductChangeShow');
391 392
         })->prefix('merchant.store.product.Product');
392 393