wugg 1 vuosi sitten
vanhempi
commit
ef276e2e23

+ 4 - 4
app/admin/controller/Good.php

@@ -5,7 +5,7 @@ namespace app\admin\controller;
 
 use app\admin\model\DataGroup as DataGroupModel;
 use app\admin\model\GoodCombind;use app\admin\model\GoodLog;
-use app\admin\model\GoodStock;use app\txx\model\YzGood;
+use app\admin\model\GoodStock;use app\txx\model\ActGoodurl;use app\txx\model\YzGood;
 use think\App;
 use think\db\Raw;
 use think\facade\Db;
@@ -305,6 +305,7 @@ class Good extends Base
 
         $data = [];
         $tmp_cat = [];
+        $actUrl=new ActGoodurl();
         foreach ($list as $value) {
             if(!isset($tmp_cat[$value['cat_id']])) $tmp_cat[$value['cat_id']] = made($value['cat_id'], []);
             $value['cat_info'] = $tmp_cat[$value['cat_id']];
@@ -317,13 +318,12 @@ class Good extends Base
             $value["brand_name"] = $brand[$value['brand_id']]??'';//isset($brand['brand_name']) ? $brand['brand_name'] : "";
 //            $unit = Db::name("unit")->field('id,unit')->where(["id" => $value['good_unit']])->find();
             $value['unit'] = $unit[$value['good_unit']]??'';//isset($unit['unit']) ? $unit['unit'] : "";
-//            $company = Db::name("business")->field('id,company')->where(["companyNo" => $value['companyNo']])->find();
+
             $value['company'] = $names['data'][$value['companyNo']]??'';//isset($company['company']) ? $company['company'] : "";
             $value['stock_total'] = Db::name("good_stock")->where(['spuCode' => $value['spuCode'], "is_del" => 0])->sum("usable_stock");
             $value['status'] = $value['exam_status'];
             $value['exclusive'] = makeExcluse($value['is_exclusive']);
-//            $value['good_info_img']=$value['good_info_img'];
-//            $value['good_img']=$value['good_img'];
+            $value['is_act_url'] =$actUrl->where(["act_good_id"=>$value["platform_youzan_id"],"is_del"=>0])->findOrEmpty()->isEmpty();
             $spec = Db::name("good_spec")
                 ->where(["spuCode" => $value['spuCode'], "is_del" => 0])
                 ->select()

+ 58 - 0
app/txx/controller/Base.php

@@ -0,0 +1,58 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\txx\controller;
+
+use think\App;
+use think\exception\HttpResponseException;
+use think\Response;
+
+class Base extends \app\admin\controller\Base
+{
+	public function __construct(App $app) {
+  	parent::__construct($app);
+  }
+  
+   /**
+	* @param string $message
+	* @param int $code
+	* @param null $data
+	 */
+    public function error($message='',$code=1003,$data=null){
+        $this->result($message,$data,$code);
+    }
+    /**
+	* @param string $message
+	* @param int $code
+	* @param null $data
+	 */
+     public function success($message='',$data=null,$code=0){
+        $this->result($message,$data,$code);
+    }
+    
+     /**
+	* @param string $msg
+	* @param null $data
+	* @param int $code
+	* @param string|null $type
+	* @param array $header
+	* @param array $options
+	 */
+    private function result(string $msg, $data = null, int $code = 0, string $type = 'json', array $header = [], array
+    $options = [])
+    {
+        $result = [
+            'code' => $code,
+            'message'  => $msg,
+            'data' => $data,
+        ];
+        $code = 200;
+        if (isset($header['statuscode'])) {
+            $code = $header['statuscode'];
+            unset($header['statuscode']);
+        }
+
+        $response = Response::create($result, $type, $code)->header($header)->options($options);
+         throw new HttpResponseException($response);
+    }
+}

+ 90 - 0
app/txx/controller/TxGood.php

@@ -0,0 +1,90 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\txx\controller;
+
+use app\admin\model\Brand;use app\admin\model\Cat;use app\admin\model\PlatformYouzan;use app\admin\model\Unit;use app\report\model\GoodSpec;use app\report\model\SpecValue;use app\txx\model\ActGoodurl;use app\txx\model\YzGood;use think\App;use think\facade\Db;use think\facade\Validate;
+
+class TxGood extends Base
+{
+	private $platform_id=37;
+	public function __construct(App $app) {
+		parent::__construct($app);
+	}
+	/**
+	* 1. 十万订单每秒热点数据架构如何优化
+	* 2. Redis集群崩溃时如何保证秒杀系统高可用
+	* 3. Redis主从切换导致库存同步异常以及超卖问题
+	* 4. 秒杀链路中Redis与MQ如何保证事务一致性
+	* 5. 线上MQ百万秒杀订单积压如何优化
+	* 6. 如何用Redis高效实现12306的复杂售票业务
+	* 7. 新浪微博突发事件如何做好Redis缓存的高可用
+	* 8. 高并发场景缓存穿透&失效&雪崩如何解决
+	* 9. Redis集群架构如何抗住12306与双11的洪峰流量
+	* 10. Redis缓存与数据库双写不一致如何解决
+	* 11. 双十一亿级用户日活统计如何用Redis快速计算
+	* 12. 双十一电商推荐系统如何用Redis实现
+	* 13. 日均百亿级微信红包系统如何架构
+	* 14. 类似微信的社交App朋友圈关注模型如何设计实现
+	* 15. 美团单车如何基于Redis快速找到附近的车
+	* 16. Redis分布式锁主从架构锁失效问题如何解决
+	* 17. 超大并发的分布式锁架构该如何设计
+	* 18. Redis底层ZSet跳表是如何设计与实现的
+	* 19. Redis底层ZSet实现压缩列表和跳表如何选择
+	* 20. Redis6.0多线程模型比单线程优化在哪里了
+    */
+	public function AddCouponUrl(){
+		$param = $this->request->param(["skuCode"=>"","coupon_url"=>""],"post","trim");
+		$valid =Validate::rule(["skuCode|商品上线编号"=>"require","coupon_url|商品优惠券链接"=>"require"]);
+		if($valid->check($param)==false)$this->error($valid->getError());
+		$youzan = new PlatformYouzan();
+		$info = $youzan->where(["skuCode"=>$param['skuCode'],"is_del"=>0])->findOrEmpty();
+		if($info->isEmpty())$this->error("未找到商品信息");
+		if($info->exam_status!=6)$this->error("商品未上线");
+		$actUrl= new ActGoodurl();
+		$isT = $actUrl->where(["act_good_id"=>$info->id,"is_del"=>0])->findOrEmpty();
+		if($isT->isEmpty()){
+			$data=[
+				"act_good_url"=>$param['coupon_url'],
+				"act_good_id"=>$info->id,
+				"apply_id"=>$this->uid,
+				"apply_name"=>$this->uname,
+				];
+		}else{
+			$data=[
+				'act_good_url'=>$param['coupon_url'],
+				'apply_id'=>$this->uid,
+				'apply_name'=>$this->uname,
+				];
+		}
+		$up=$isT->save($data);
+		$up?$this->success("链接上传成功"):$this->error("链接上传失败");
+	}
+	
+	public function list(){
+		$param = $this->request->param(["page"=>1,"size"=>15,"good_name"=>""],'post','trim');
+		$where = [['b.is_del', '=', 0],['a.is_del', '=', 0],['b.platform_id','=',$this->platform_id],['b.exam_status',
+		'=',6]];
+		$param['good_name']!=''??$where[]=["c.good_name","like","%{$param['good_name']}%"];
+		$actUrl= new ActGoodurl();
+		$list = $actUrl->alias("a")
+		->leftJoin("platform_youzan b","a.act_good_id=b.id")
+		->leftJoin('good_basic c', 'c.spuCode=b.spuCode')
+		->where($where)
+		->field("b.skuCode,b.plat_code,b.id as platform_youzan_id,a.act_good_url,
+		            c.good_name,c.good_img,c.good_info_img,c.good_thumb_img,c.brand_id,c.cat_id,
+		            c.good_unit,a.addtime,a.updatetime,b.spuCode,b.sale_price,b.final_price")
+		->order("a.id desc")
+		->paginate(["list_rows"=>$param['size'],"page"=>$param["page"]]);
+		foreach ($list->items() as $item){
+			$item['brand_name'] =Brand::where("id",$item['brand_id'])->value("brand_name",'');
+			$item['good_unit'] =Unit::where("id",$item['good_unit'])->value("unit",'');
+			$item['cat_name'] =Cat::where("id",$item['cat_id'])->value("search",'');
+			$item['good_url'] =YzGood::where(['item_no'=>$item['skuCode'],'is_del'=>0])->value('detail_url','');
+			$item['origin_price'] =YzGood::where(['item_no'=>$item['skuCode'],'is_del'=>0])->value('origin','');
+			$item['spec_info'] =GoodSpec::where(["spuCode" => $item['spuCode'], "is_del" => 0])->with(["spec",
+			"Spec_info"])->select();
+		}
+		$this->success('获取成功',["list"=>$list->items(),"count"=>$list->total()]);
+	}
+}

+ 14 - 0
app/txx/model/ActGoodurl.php

@@ -0,0 +1,14 @@
+<?php
+declare (strict_types = 1);
+
+namespace app\txx\model;
+
+use think\Model;
+
+/**
+ * @mixin \think\Model
+ */
+class ActGoodurl extends Model
+{
+    //
+}