Commit e2dcf593 authored by jianghaiming's avatar jianghaiming

update:set

parent 6cb88e3b
...@@ -31,5 +31,7 @@ class DistributorException extends BaseException ...@@ -31,5 +31,7 @@ class DistributorException extends BaseException
12 => '类型不能为空', 12 => '类型不能为空',
13 => '姓名不能大于40字符', 13 => '姓名不能大于40字符',
14 => '用户id不能能为空', 14 => '用户id不能能为空',
15 => '活动id不能能为空',
16 => '商品id不能能为空',
]; ];
} }
\ No newline at end of file
<?php
namespace App\Models\distribution\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class Distribution extends MysqlBase
{
const TABLE_NAME = 'distribution';
const CONFIG_INDEX = 'distribution';
const PRIMARY_KEY = 'id';
public static function getRecord($where, $colums = [])
{
if (empty($colums)) {
$colums = '*';
}
return self::get($colums, $where);
}
public static function getRecordMaster($where, $colums = [])
{
if (empty($colums)) {
$colums = '*';
}
return self::selectMaster($colums, $where);
}
public static function insertRecord($colums)
{
return self::insert($colums);
}
public static function updateRecord($colums, $where)
{
return self::update($colums, $where);
}
public static function save($data, $where = [])
{
if (empty($where)) {
return self::insert($data);
}
return self::update($data, $where);
}
public static function deleteRecord($where)
{
return self::delete($where);
}
public static function getRecords($where, $colums = [])
{
if (empty($colums)) {
$colums = '*';
}
return self::select($colums, $where);
}
public static function getCount($where, $columns = "*")
{
return self::count($columns, $where);
}
}
<?php
namespace App\Models\shop\mysql;
use Api\PhpUtils\Mysql\MysqlBase;
class SubShop extends MysqlBase
{
const TABLE_NAME = 'sub_shop';
const CONFIG_INDEX = 'goods';
const PRIMARY_KEY = 'stores_id';
public static function getRecord($where, $colums = [])
{
if (empty($colums)) {
$colums = '*';
}
return self::get($colums, $where);
}
public static function getRecordMaster($where, $colums = [])
{
if (empty($colums)) {
$colums = '*';
}
return self::selectMaster($colums, $where);
}
public static function insertRecord($colums)
{
$options['rowCount'] = true;
return self::insert($colums,$options);
}
public static function updateRecord($colums, $where)
{
return self::update($colums, $where);
}
public static function save($data, $where = [])
{
if (empty($where)) {
return self::insert($data);
}
return self::update($data, $where);
}
public static function deleteRecord($where)
{
return self::delete($where);
}
public static function getRecords($where, $colums = [])
{
if (empty($colums)) {
$colums = '*';
}
return self::select($colums, $where);
}
public static function getCount($where, $columns = "*")
{
return self::count($columns, $where);
}
}
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
use App\Base\Base; use App\Base\Base;
use App\Services\Marketing\MarketingGoodsService; use App\Services\Marketing\MarketingGoodsService;
use App\Exception\custom\DistributorException; use App\Exception\custom\DistributorException;
use Helpers\Aes;
class MarketingGoodsController extends Base class MarketingGoodsController extends Base
{ {
...@@ -14,21 +15,37 @@ class MarketingGoodsController extends Base ...@@ -14,21 +15,37 @@ class MarketingGoodsController extends Base
{ {
$params = $this->params; $params = $this->params;
// $marketingList = Marketing::getMarketingList(['online_status' => 1,'start_time' => date("Y-m-d H:i:s"),'end_time' => date("Y-m-d H:i:s")]); $list = MarketingGoodsService::marketingGoodsList($params);
$this->success($list);
}
public function generate_share_goodsAction()
{
$params = $this->params;
$userId = !empty($params['user_id']) ? $params['user_id'] : '';
$marketingId = !empty($params['marketing_id']) ? $params['marketing_id'] : '';
$goodsSkuId = !empty($params['goods_sku_id']) ? $params['goods_sku_id'] : '';
$content = $userId .'_' .$marketingId . '_' .$goodsSkuId;
// print_r( $marketingList); if (empty($userId)) {
throw new DistributorException(['cus'=>14]);
}
// die(); if (empty($marketingId)) {
throw new DistributorException(['cus'=>15]);
}
if (empty($goodsSkuId)) {
throw new DistributorException(['cus'=>16]);
}
$distributionList = MarketingGoodsService::marketingGoodsList($params);
print_r($distributionList);
die(); $goodsShareId = Aes::encrypt($content);
$this->success($distributionList); $data['goods_share_id'] = $goodsShareId;
$result = ['result' => $data];
$this->success($result);
} }
......
...@@ -15,8 +15,14 @@ class MarketingGoodsService ...@@ -15,8 +15,14 @@ class MarketingGoodsService
{ {
public static function marketingGoodsList($params) public static function marketingGoodsList($params)
{ {
$params['page'] = !empty($params['page']) ? $params['page'] : 1;
$limit = !empty($params['page_size']) ? $params['page_size'] : 20;
$page = ($params['page'] - 1) * $limit;
$where['LIMIT'] = [$page, $limit];
$where['ORDER'] = ["create_time" => "DESC"];
$where = [];
$marketingWhere = [ $marketingWhere = [
"end_time[>]" => date("Y-m-d"), "end_time[>]" => date("Y-m-d"),
"online_status" => 1, "online_status" => 1,
...@@ -28,51 +34,39 @@ class MarketingGoodsService ...@@ -28,51 +34,39 @@ class MarketingGoodsService
$goodsSkuId = array_column($data, 'goods_sku_id'); $goodsSkuId = array_column($data, 'goods_sku_id');
$goodsSkuList = GoodsSku::getRecordMaster(['goods_sku_id' => $goodsSkuId]); $goodsSkuList = GoodsSku::getRecordMaster(['goods_sku_id' => $goodsSkuId]);
$goodsSkuList = array_column($goodsSkuList,null,'goods_sku_id'); $goodsSkuList = array_column($goodsSkuList,null,'goods_sku_id');
$lastData = end($data);
$lastId = !empty($lastData['id']) ? $lastData['id'] : '';
$shopId = []; $shopId = [];
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$shopId[$key] = !empty($goodsSkuList[$value['goods_sku_id']]['shop_id']) ? $goodsSkuList[$value['goods_sku_id']]['shop_id'] : ''; $shopId[$key] = !empty($goodsSkuList[$value['goods_sku_id']]['shop_id']) ? $goodsSkuList[$value['goods_sku_id']]['shop_id'] : '';
} }
$subShopList = SubShop::getRecordMaster(['shop_id' => $shopId]);
$subShopList = array_column($subShopList,null,'shop_id');
$subShopList = SubShop::getRecords(['shop_id' => $shopId]);
print_r($subShopList);
die();
$list = []; $list = [];
$i = 0;
foreach ($data as $key => $value) { foreach ($data as $key => $value) {
$list[$key] = $value; $list[$i] = $value;
$list[$key]['life_account_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['life_account_id']) ? $goodsSkuList[$value['goods_sku_id']]['life_account_id'] : ''; $list[$i]['life_account_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['life_account_id']) ? $goodsSkuList[$value['goods_sku_id']]['life_account_id'] : '';
$list[$key]['shop_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['shop_id']) ? $goodsSkuList[$value['goods_sku_id']]['shop_id'] : ''; $list[$i]['shop_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['shop_id']) ? $goodsSkuList[$value['goods_sku_id']]['shop_id'] : '';
$list[$key]['goods_name'] = !empty($goodsSkuList[$value['goods_sku_id']]['name']) ? $goodsSkuList[$value['goods_sku_id']]['name'] : ''; $list[$i]['goods_name'] = !empty($goodsSkuList[$value['goods_sku_id']]['name']) ? $goodsSkuList[$value['goods_sku_id']]['name'] : '';
$list[$key]['goods_desc'] = !empty($goodsSkuList[$value['goods_sku_id']]['desc']) ? $goodsSkuList[$value['goods_sku_id']]['desc'] : ''; $list[$i]['goods_desc'] = !empty($goodsSkuList[$value['goods_sku_id']]['desc']) ? $goodsSkuList[$value['goods_sku_id']]['desc'] : '';
$list[$key]['goods_spu_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['goods_spu_id']) ? $goodsSkuList[$value['goods_sku_id']]['goods_spu_id'] : ''; $list[$i]['goods_spu_id'] = !empty($goodsSkuList[$value['goods_sku_id']]['goods_spu_id']) ? $goodsSkuList[$value['goods_sku_id']]['goods_spu_id'] : '';
$list[$key]['original_price'] = !empty($goodsSkuList[$value['goods_sku_id']]['original_price']) ? $goodsSkuList[$value['goods_sku_id']]['original_price'] : ''; $list[$i]['original_price'] = !empty($goodsSkuList[$value['goods_sku_id']]['original_price']) ? $goodsSkuList[$value['goods_sku_id']]['original_price'] : '';
$list[$key]['price'] = !empty($goodsSkuList[$value['goods_sku_id']]['price']) ? $goodsSkuList[$value['goods_sku_id']]['price'] : ''; $list[$i]['price'] = !empty($goodsSkuList[$value['goods_sku_id']]['price']) ? $goodsSkuList[$value['goods_sku_id']]['price'] : '';
$list[$key]['total_amount_order'] = !empty($goodsSkuList[$value['goods_sku_id']]['total_amount_order']) ? $goodsSkuList[$value['goods_sku_id']]['total_amount_order'] : ''; $list[$i]['total_amount_order'] = !empty($goodsSkuList[$value['goods_sku_id']]['total_amount_order']) ? $goodsSkuList[$value['goods_sku_id']]['total_amount_order'] : '';
$list[$key]['url'] = !empty($goodsSkuList[$value['goods_sku_id']]['url']) ? $goodsSkuList[$value['goods_sku_id']]['url'] : ''; $list[$i]['url'] = !empty($goodsSkuList[$value['goods_sku_id']]['url']) ? $goodsSkuList[$value['goods_sku_id']]['url'] : '';
$shopId = !empty($list[$i]['shop_id']) ? $list[$i]['shop_id'] : '';
$shopId = !empty($list[$key]['shop_id']) ? $list[$key]['shop_id'] : ''; $list[$i]['shop_name'] = !empty($subShopList[$shopId]['name']) ? $subShopList[$shopId]['name'] : '';
$i++;
} }
$result = ['result' => $list ,'last_id' => $lastId];
return $result;
return $list;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment