zxiansheng преди 3 години
родител
ревизия
1bb3e2cba6

+ 3 - 0
backendApi/modules/v1/controllers/ShopController.php

@@ -137,6 +137,9 @@ class ShopController extends BaseController {
         $data = ShopGoods::findOneAsArray('ID=:ID', [':ID' => $id]);
         $data['SELL_TYPE'] = explode(',',$data['SELL_TYPE']);
         $data['GIFT_TYPE'] = explode(',',$data['GIFT_TYPE']);
+        if ($data['TYPE'] == 1 || $data['TYPE'] == 2) {
+            $data['SELL_DISCOUNT'] = ShopGoods::GOODS_TYPE[$data['TYPE']]['discount']/100;
+        }
         return static::notice(['goodsInfo'=>$data,'sellType' => ShopGoods::SALE_TYPE, 'goodsType' => ShopGoods::GOODS_TYPE, 'giftType' => ShopGoods::GIFT_TYPE]);
     }
 

+ 3 - 3
backendApi/modules/v1/models/lists/shop/GoodsList.php

@@ -83,7 +83,7 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
                     'headerOther' => ['width' => '150'],
                 ],
                 'SELL_TYPE' => [
-                    'header' => '出售方式',
+                    'header' => '复消购买方式',
                     'value' => function($row){
                         $sellType = ShopGoods::SALE_TYPE;
                         $sel = explode(',',$row['SELL_TYPE']);
@@ -160,12 +160,12 @@ class GoodsList extends \common\libs\dataList\DataList implements DataListInterf
     {
         if(!$this->filterTypes){
             $this->filterTypes = [
-                'TYPE' => ['isUserTable' => false, 'name' => '商品来源', 'other' => 'select', 'selectData' => [['id' => 1, 'name' => '国内商品'], ['id' => 2, 'name' => '进口商品']]],
+                //'TYPE' => ['isUserTable' => false, 'name' => '商品来源', 'other' => 'select', 'selectData' => [['id' => 1, 'name' => '国内商品'], ['id' => 2, 'name' => '进口商品']]],
                 'GIFT_TYPE' => ['isUserTable' => false, 'name' => '商品类型', 'other' => 'select', 'selectData' => [['id' => 1, 'name' => '报单区'], ['id' => 2, 'name' => '复消区'], ['id' => 3, 'name' => '工作室报单'], ['id' => 4, 'name' => '工作室复消']]],
                 'STATUS'=> ['name'=> '状态', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> '已下架'],['id'=> 1, 'name'=> '已上架']]],
                 'GOODS_NAME'=> ['name'=> '商品名称'],
                 'GOODS_NO'=> ['name'=> '商品编号'],
-                'SELL_TYPE'=> ['name'=> '出售方式', 'other'=> 'select', 'selectData'=> [['id'=> 1, 'name'=> '余额购买'],['id'=> 2, 'name'=> '积分购买']]],
+                'SELL_TYPE'=> ['name'=> '复消购买方式', 'other'=> 'select', 'selectData'=> [['id'=> 1, 'name'=> '余额购买'],['id'=> 2, 'name'=> '积分购买']]],
                 'SELL_PRICE'=> ['name'=> '销售价格'],
                 'PRICE_PV'=> ['name'=> '销售PV'],
             ];

+ 18 - 6
common/models/forms/OrderForm.php

@@ -288,9 +288,15 @@ class OrderForm extends Model
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                 if($goods['STORE_NUMS']>0){
-                    $discount = $goodsType[$goods['TYPE']]['discount'];
-                    $realPrice = $goods['SELL_PRICE'] * $discount/100;
-                    $realPv = $goods['PRICE_PV'] * $discount/100;
+                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
+                        $discount = $goodsType[$goods['TYPE']]['discount'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
+                        $realPv = $goods['PRICE_PV'] * $discount/100;
+                    } else {
+                        $discount = $goods['SELL_DISCOUNT'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount;
+                        $realPv = $goods['PRICE_PV'] * $discount;
+                    }
                     $totalAmount += $realPrice * intval($v);
                     $totalPv += $realPv * intval($v);
 //                    if($this->payType=='cash') {
@@ -440,9 +446,15 @@ class OrderForm extends Model
             if ($v) {
                 $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
                 if($goods['STORE_NUMS']>0){
-                    $discount = $goodsType[$goods['TYPE']]['discount'];
-                    $realPrice = $goods['SELL_PRICE'] * $discount/100;
-                    $realPv = $goods['PRICE_PV'] * $discount/100;
+                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
+                        $discount = $goodsType[$goods['TYPE']]['discount'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
+                        $realPv = $goods['PRICE_PV'] * $discount/100;
+                    } else {
+                        $discount = $goods['SELL_DISCOUNT'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount;
+                        $realPv = $goods['PRICE_PV'] * $discount;
+                    }
                     $totalAmount += $realPrice * intval($v);
                     $totalPv += $realPv * intval($v);
                     $this->_orderGoods[] = [

+ 1 - 1
common/models/forms/ShopGoodsForm.php

@@ -192,7 +192,7 @@ class ShopGoodsForm extends Model
         try {
             $model = $this->_model;
             $model->GOODS_NAME = $this->goodsName;
-            // $model->TYPE = $this->type;
+            $model->TYPE = 0;
             $model->SELL_DISCOUNT = $this->sellDiscount;
             $model->GIFT_TYPE = implode(',',$this->giftType);
             $model->SELL_TYPE = implode(',',$this->sellType);

+ 12 - 2
frontendApi/modules/v1/controllers/ShopController.php

@@ -43,7 +43,12 @@ class ShopController extends BaseController {
             'from' => ShopGoods::tableName(),
         ]);
         foreach ($data['list'] as $key => $value) {
-            $data['list'][$key]['DISCOUNT'] = ShopGoods::GOODS_TYPE[$value['TYPE']]['discount'];
+            if ($value['TYPE'] == 1 || $value['TYPE'] == 2) {
+                $data['list'][$key]['DISCOUNT'] = ShopGoods::GOODS_TYPE[$value['TYPE']]['discount'];
+            } else {
+                $data['list'][$key]['DISCOUNT'] = $value['SELL_DISCOUNT']*100;
+            }
+            // $data['list'][$key]['DISCOUNT'] = ShopGoods::GOODS_TYPE[$value['TYPE']]['discount'];
         }
         return static::notice($data);
     }
@@ -180,7 +185,12 @@ class ShopController extends BaseController {
             'from' => ShopGoods::tableName(),
         ]);
         foreach ($data['list'] as $key => $value) {
-            $data['list'][$key]['DISCOUNT'] = ShopGoods::GOODS_TYPE[$value['TYPE']]['discount'];
+            if ($value['TYPE'] == 1 || $value['TYPE'] == 2) {
+                $data['list'][$key]['DISCOUNT'] = ShopGoods::GOODS_TYPE[$value['TYPE']]['discount'];
+            } else {
+                $data['list'][$key]['DISCOUNT'] = $value['SELL_DISCOUNT']*100;
+            }
+            //$data['list'][$key]['DISCOUNT'] = ShopGoods::GOODS_TYPE[$value['TYPE']]['discount'];
         }
         return static::notice($data);
     }