afa 7 månader sedan
förälder
incheckning
81941c7720

+ 1 - 1
application/admin/view/general/announcement/add.html

@@ -8,7 +8,7 @@
         </div>
         <label class="control-label col-xs-12 col-sm-2">{:__('所属语言')}:</label>
         <div class="col-xs-12 col-sm-3">
-            <input id="c-to_lang" data-rule="required" data-source='[{"id":"0","title":"中文"},{"id":"1","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="">
+            <input id="c-to_lang" data-rule="required" data-source='[{"id":"zh","title":"中文"},{"id":"en","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="">
         </div>
     </div>
     <div class="form-group">

+ 1 - 1
application/admin/view/general/announcement/edit.html

@@ -8,7 +8,7 @@
         </div>
         <label class="control-label col-xs-12 col-sm-2">{:__('所属语言')}:</label>
         <div class="col-xs-12 col-sm-3">
-            <input id="c-to_lang" data-rule="required" data-source='[{"id":"0","title":"中文"},{"id":"1","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="{$row.to_lang|htmlentities}">
+            <input id="c-to_lang" data-rule="required" data-source='[{"id":"zh","title":"中文"},{"id":"en","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="{$row.to_lang|htmlentities}">
         </div>
     </div>
     <div class="form-group">

+ 1 - 1
application/admin/view/product/synthesis/add.html

@@ -14,7 +14,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('To_lang')}:</label>
         <div class="col-xs-12 col-sm-3">
-            <input id="c-to_lang" data-rule="required" data-source='[{"id":"0","title":"中文"},{"id":"1","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="">
+            <input id="c-to_lang" data-rule="required" data-source='[{"id":"zh","title":"中文"},{"id":"en","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="">
         </div>
         <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
         <div class="col-xs-12 col-sm-3">

+ 1 - 1
application/admin/view/product/synthesis/edit.html

@@ -14,7 +14,7 @@
     <div class="form-group">
         <label class="control-label col-xs-12 col-sm-2">{:__('To_lang')}:</label>
         <div class="col-xs-12 col-sm-3">
-            <input id="c-to_lang" data-rule="required" data-source='[{"id":"0","title":"中文"},{"id":"1","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="{$row.to_lang|htmlentities}">
+            <input id="c-to_lang" data-rule="required" data-source='[{"id":"zh","title":"中文"},{"id":"en","title":"英文"}]' data-field="title" class="form-control selectpage" name="row[to_lang]" type="text" value="{$row.to_lang|htmlentities}">
         </div>
         <label class="control-label col-xs-12 col-sm-2">{:__('Weigh')}:</label>
         <div class="col-xs-12 col-sm-3">

+ 3 - 3
application/api/controller/Announcement.php

@@ -9,13 +9,13 @@ class Announcement extends Api
 {
 
     protected array $noNeedLogin = ['list','show'];
-    const toLang = ['zh' => 0, 'en' => 1];
-    protected int $lan = 0;
+
+    protected string $lan = '';
 
     public function _initialize()
     {
         parent::_initialize();
-        $this->lan = self::toLang[$this->request->getLan()];
+        $this->lan = $this->request->getLan();
     }
 
     //列表

+ 34 - 42
application/api/controller/Synthesis.php

@@ -4,8 +4,8 @@
 namespace app\api\controller;
 
 use app\common\controller\Api;
-use app\common\model\UserModel;
-use app\common\model\UserPathModel;
+use app\common\model\ProductLists;
+use app\common\model\ProductOrder;
 use app\common\model\Synthesis as SynthesisModel;
 use fast\Action;
 use fast\Asset;
@@ -18,58 +18,50 @@ use think\Log;
 class Synthesis extends Api
 {
 
+    protected string $lan = '';
+
+    public function _initialize()
+    {
+        parent::_initialize();
+        $this->lan = $this->request->getLan();
+    }
 
     public function list(SynthesisModel $synthesis)
     {
         $list = $synthesis->alias('a')
         ->join("product_list b", "a.product_id = b.id", "left")
-        ->join("user u", "a.user_id = u.id", "left")
-        ->join("products d", "b.type_id = d.id", "left")
-        ->join("product_area dr", "dr.id = a.area_id", "left") //地区
-        ->field('a.id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,price,u.nickname,d.'.$this->lan.'_title as title,dr.address')
-        ->where('a.status', $synthesis::Normal)
-        ->where($map)
-        ->order($order)
+        ->field('a.id,a.title,a.start_time,a.end_time,b.thum as img_url')
+        ->where('a.status', $synthesis::Normal)->where('a.to_lang', $this->lan)
+        ->order('a.weigh desc')
         ->paginate($this->pageSize);
-    $this->success('', $list);
+        $this->success('', $list);
     }
 
 
-    /*
-     * 更新上级
+     /*
+     * 合成详情
      */
-    public function change_parent()
+    public function detail(ProductLists $productLists, ProductOrder $productOrder)
     {
-        //3.更新主表会员上级
-        dump('重建网体');
-        $user_list = Db::table('user_1')
-            ->order('distance')
-            ->select();
-        $i = 0;
-        foreach ($user_list as $user){
-            $parent_info = (new UserModel())
-                ->where('address', $user['parent_address'])
-                ->find();
-            if(!empty($parent_info)){
-                $is = Db::table('user')
-                    ->where('id', $user['id'])
-                    ->update([
-                        'parent_id' => $parent_info['id']
-                    ]);
-                //删除网体
-                (new UserPathModel())
-                    ->where('user_id', $user['id'])
-                    ->delete();
-
-                // 创建网体
-                (new UserPathModel())->createPath($user['id'], $parent_info['id']);
-                $i++;
-            } else{
-                dump($user['id'] . '--无上级');
-            }
+        $id = $this->request->param('id', 0, 'intval');
+        if(empty($id)) $this->error(__("参数有误,无可用产品"));
+        //合成详情
+        $synthesis = SynthesisModel::get($id);
+        if (!empty($synthesis)) {
+            //条件一
+            $lan = $this->request->getLan();
+            $material_one = $productLists->getBySynthesisProduct($synthesis->material_one, $lan);
+            $synthesis->material_one = $productOrder->getByOrderProductNum($material_one, $synthesis->material_one_num, $this->auth->id);
+            //条件二
+            $material_two = $productLists->getBySynthesisProduct($synthesis->material_two, $lan);
+            $synthesis->material_two = $productOrder->getByOrderProductNum($material_two, $synthesis->material_one_num, $this->auth->id);
+            //条件三
+            $material_three = $productLists->getBySynthesisProduct($synthesis->material_three, $lan);
+            $synthesis->material_three = $productOrder->getByOrderProductNum($material_three, $synthesis->material_one_num, $this->auth->id);
         }
-
-        halt($i);
+        $this->success('', $synthesis);
+     
+       
     }
 
  

+ 8 - 0
application/common/model/ProductLists.php

@@ -37,6 +37,14 @@ class ProductLists extends Model
         self::Normal            => '正常'
     ];
 
+    //获取产品信息
+    public static function  getBySynthesisProduct($product_id, $lan = 'zh')
+    {    
+        if(empty($product_id)) return [];
+        $list = self::whereIn('id', $product_id)->column('id,thum,'.$lan.'_name as name');
+        return $list;
+    }
+
     //地区
     public function productArea()
     {

+ 12 - 1
application/common/model/ProductOrder.php

@@ -112,7 +112,18 @@ class ProductOrder extends Model
         ]);
     }
 
-
+    //获取持有产品数量
+    public static function getByOrderProductNum($productId, $num, $uid){
+        if(empty($productId)) return 0;
+        foreach ($productId as &$item) {
+            $item['num'] = $num;
+            $count = self::where('user_id', $uid)->where('product_id', $item['id'])->where('type_id', self::Popular)->where('status', self::Paid)->sum('num');
+            if(empty($count)) $count = 0;
+            $item['hold_num'] = $count;
+        }
+        return $productId;
+    }
+       
     // 获取订单状态
     public static function getProductOrder($orderId, $status, string $field){
         return self::alias('a')->where('a.id', $orderId)

+ 1 - 1
public/assets/js/backend/general/announcement.js

@@ -31,7 +31,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'img_url', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                         {field: 'weigh', title: __('Weigh'), operate: false},
                         {field: 'status', title: __('Status'), searchList: {"1":__('上架'),"2":__('下架')}, formatter: Table.api.formatter.toggle},
-                        {field: 'to_lang', title: __('所属语言'), operate: false,  searchList: {0:__('中文'), 1:__('英文')}, formatter: Table.api.formatter.flag},
+                        {field: 'to_lang', title: __('所属语言'), operate: false,  searchList: {'zh':__('中文'), 'en':__('英文')}, formatter: Table.api.formatter.flag},
                         {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'updatetime', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}

+ 1 - 1
public/assets/js/backend/product/synthesis.js

@@ -30,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'id', title: __('Id')},
                         {field: 'product_id', title: __('Product_id')},
                         {field: 'title', title: __('Title')},
-                        {field: 'to_lang', title: __('To_lang'), operate: false,  searchList: {0:__('中文'), 1:__('英文')}, formatter: Table.api.formatter.flag},
+                        {field: 'to_lang', title: __('To_lang'), operate: false,  searchList: {'zh':__('中文'), 'en':__('英文')}, formatter: Table.api.formatter.flag},
                         {field: 'material_one', title: __('Material_one'), operate: 'LIKE'},
                         {field: 'material_one_num', title: __('Material_one_num')},
                         {field: 'material_two', title: __('Material_two'), operate: 'LIKE'},