pull/1/head
wangmingchuan321@qq.com 12 months ago
parent a9a16ed9df
commit 22314b4253
  1. 28
      app/api/controller/Goods.php
  2. 8
      app/api/controller/Order.php
  3. 49
      app/api/model/Goods.php
  4. 8
      app/api/model/Order.php
  5. 18
      app/command/test.php
  6. 2
      app/common/model/Category.php

@ -12,6 +12,7 @@ declare (strict_types=1);
namespace app\api\controller;
use app\common\enum\dealer\withdraw\PayType;
use think\response\Json;
use app\api\model\{Goods as GoodsModel};
use app\api\service\{User as UserService, Goods as GoodsService};
@ -75,7 +76,10 @@ class Goods extends Controller
$param = $this->request->param();
$model = new GoodsModel;
$goodsInfo = $model->presale($param);
return $this->renderSuccess($goodsInfo);
if ($goodsInfo) {
return $this->renderSuccess('预约成功');
}
return $this->renderError('您已经预约过了');
}
public function browseDel()
@ -89,6 +93,27 @@ class Goods extends Controller
return $this->renderError('删除失败');
}
public function presaleList()
{
$param = $this->request->param();
$model = new GoodsModel;
$list = $model->presaleList($param);
return $this->renderSuccess(compact('list'));
}
public function canlpresale()
{
$param = $this->request->param();
$model = new GoodsModel;
$goodsInfo = $model->canlpresale($param);
if ($goodsInfo) {
return $this->renderSuccess('成功');
}
return $this->renderError('失败');
}
/**
* 获取商品详情(基础信息)
* @param int $goodsId 商品ID
@ -154,6 +179,7 @@ class Goods extends Controller
return $this->renderSuccess($goodsList);
}
public function getCommonConfig(): Json
{
$service = new GoodsService;

@ -77,10 +77,10 @@ class Order extends Controller
{
// 订单详情
$model = OrderModel::getUserOrderDetail($orderId);
//todo wmc 自提时间
$model->ziti_time = '2024-03-02 22:22:22';
$model->ziti_status = 0;//0没提 1已提货
$model->ziti_image = ['https://www.saas.njrenzhou.com/uploads/10001/20240116/18adc22ad9ea021ab2586878fe1035b0.png'];
//自提时间
// $model->ziti_time = '2024-03-02 22:22:22';
// $model->ziti_status = 0;//0没提 1已提货
// $model->ziti_image = ['https://www.saas.njrenzhou.com/uploads/10001/20240116/18adc22ad9ea021ab2586878fe1035b0.png'];
return $this->renderSuccess([
'order' => $model, // 订单详情

@ -27,6 +27,9 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use app\store\model\goods\GoodsPrice as GoodsPriceModel;
use app\api\model\PreSale;
use app\api\model\PreSaleMessage;
use app\api\model\PreSaleLog;
/**
* 商品模型
@ -116,6 +119,27 @@ class Goods extends GoodsModel
return $this->setGoodsListDataFromApi($list);
}
public function presale()
{
$userId = UserService::getCurrentLoginUserId(true);
$info = PreSaleLog::where([
'user_id' => $userId,
'store_id' => request()->header()['storeid'],
'goods_id' => $_POST['goods_id'],
])->find();
if (!$info) {
PreSaleLog::insert([
'user_id' => $userId,
'store_id' => request()->header()['storeid'],
'goods_id' => $_POST['goods_id'],
'ctime' => date('Y-m-d H:i:s')
]);
return true;
}
return false;
}
public function browseLog()
{
@ -159,6 +183,31 @@ class Goods extends GoodsModel
return $info;
}
public function presaleList()
{
$userId = UserService::getCurrentLoginUserId(true);
$info = PreSaleLog::alias('a')
->join('presale b', 'a.pre_id = b.id')
->join('goods c', 'c.goods_id = a.goods_id')
->where([
'a.store_id' => request()->header()['storeid'],
'a.user_id' => $userId,
])->field('c.goods_name,c.goods_price_min,a.id,b.p_time')->paginate(15);
return $info;
}
public function canlpresale()
{
$userId = UserService::getCurrentLoginUserId(true);
$info = PreSaleLog::where([
'id' => $_POST['id'],
'user_id' => $userId
])->delete();
return $info;
}
/**
* 获取商品详情 (详细数据用于页面展示)
* @param int $goodsId 商品ID

@ -133,8 +133,6 @@ class Order extends OrderModel
//这边后面改成多商户的话需要根据storeid去获取信息
$service = new StoreService;
$info = $service->data()['storeInfo']->toArray();
//todo wmc
$info['phone'] = 13770778236;
foreach ($list['data'] as &$v) {
$v['storeInfo'] = $info;
@ -158,7 +156,8 @@ class Order extends OrderModel
}
public function orderfast()
{//todo wmc
{
//催货 这边暂时没有逻辑
return 0;
}
@ -359,9 +358,6 @@ class Order extends OrderModel
//这边后面改成多商户的话需要根据storeid去获取信息
$service = new StoreService;
$info = $service->data()['storeInfo']->toArray();
//todo wmc
$info['phone'] = 13770778236;
$order->storeInfo = $info;
return $order;
}

@ -25,6 +25,7 @@ class test extends Command
protected function execute(Input $input, Output $output)
{
//todo wmc这边代码需要优化
$info = PreSale::where('status', 1)
->where('p_time', '<=', date('Y-m-d H:i:s'))
->where('is_change', '=', 0)
@ -42,9 +43,26 @@ class test extends Command
PreSale::where('id', $v['id'])
->update(['is_change' => 1]);
//获取预约信息
$prelist = PreSaleLog::where([
'store_id' => $v['store_id'],
])->whereIn('goods_id', $goodslist)->select();
//预约的用户推送消息
foreach ($prelist as $v2) {
$goodsName = GoodsModel::where([
'store_id' => $v2['store_id'],
'goods_id' => $v2['goods_id']
])->field('goods_name')->find()->goods_name;
PreSaleMessage::insert([
'user_id' => $v2['user_id'],
'goods_id' => $v2['goods_id'],
'type' => 1,
'store_id' => $v['store_id'],
'content' => '您预约的商品' . $goodsName . '已经开售啦',
'ctime' => date('Y-m-d H:i:s')
]);
}
}

@ -90,7 +90,7 @@ class Category extends BaseModel
if (!empty($_GET['is_hot']) && $_GET['is_hot'] == 1) {
$filter[] = ['is_hot', '=', $params['is_hot']];
}
// 查询列表数据
return $this->with(['image'])
->where($filter)

Loading…
Cancel
Save