lqmac 7 months ago
parent 33d6a9c0c7
commit bc2be7fe76
  1. 32
      app/admin/controller/Goods.php
  2. 11
      app/api/controller/User.php
  3. 5
      app/api/model/Goods.php
  4. 4
      app/api/model/Order.php
  5. 16
      app/api/model/user/InvoiceOrder.php
  6. 1
      app/api/service/Goods.php
  7. 4
      app/common/model/Goods.php
  8. 2
      app/store/controller/Goods.php

@ -136,6 +136,38 @@ class Goods extends Controller
// exit();
// 更新记录
if ($model->edit($this->postForm(), $model)) {
//更新来源数据为当前数据的商品
$goods_sku = GoodsModel::where('goods_id', $goodsId)->where('store_id', 0)->find();
$list = GoodsModel::where('origin_goods_id', $goodsId)->field('goods_id')->select();
if (!$list) {
return $this->renderSuccess('更新成功');
}
$goods_data = [
'goods_name' => $goods_sku->name,
'content' => $goods_sku->content,
'selling_point' => $goods_sku->selling_point,
'goods_price_min' => $goods_sku->goods_price_min,
'goods_price_max' => $goods_sku->goods_price_max,
'line_price_min' => $goods_sku->line_price_min,
'line_price_max' => $goods_sku->line_price_max,
'cost_price_min' => $goods_sku->cost_price_min,
'profit_rate' => $goods_sku->profit_rate,
'profit' => $goods_sku->profit,
'goods_source' => $goods_sku->goods_source,
'is_check' => $goods_sku->is_check,
'delivery_time' => $goods_sku->delivery_time,
'update_time' => time(),
];
GoodsModel::where('origin_goods_id', $goodsId)->update($goods_data);
$goods_sku_data = [
'goods_price' => $goods_sku->goods_price_min,
'cost_price' => $goods_sku->cost_price_min,
'update_time' => time(),
];
GoodsSku::whereIn('goods_id', array_column($list->toArray(), "goods_id"))->update($goods_sku_data);
return $this->renderSuccess('更新成功');
}
return $this->renderError($model->getError() ?: '更新失败');

@ -276,7 +276,16 @@ class User extends Controller
}
return $this->renderSuccess('提交成功,请耐心等待');
}
//订单开票
public function invoicingDel(): Json
{
$service = new InvoiceOrder();
if (!$service->invoicingDel($this->request->param())) {
return $this->renderSuccess($service->getError() ?: '操作失败');
}
return $this->renderSuccess('提交成功,请耐心等待');
}
/**
* 个人中心协议
*/

@ -590,7 +590,7 @@ class Goods extends GoodsModel
$catService = new \app\store\model\GoodsCategoryRel();
$catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id');
$goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价
$goods['discount'] = 0;
$goods['discount'] = 0.0;
//价格判断
if (UserService::isstore()) {
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds);
@ -609,6 +609,9 @@ class Goods extends GoodsModel
$goods['goods_price_min'] = $priceArr['distributionPrice'];
}
if ($goods['discount'] == 10) {
$goods['discount'] = 0.0;
}
// 会员折扣价: 商品sku列表
if ($goods->getRelation('skuList')) {

@ -28,6 +28,7 @@ use app\common\model\Order as OrderModel;
use app\common\model\TransferRecord;
use app\common\service\{Order as OrderService, order\Complete as OrderCompleteService};
use cores\exception\BaseException;
use app\api\model\order\Delivery as DeliveryModel;
/**
* 订单模型
@ -128,6 +129,7 @@ class Order extends OrderModel
$info = $info['storeInfo']->toArray();
foreach ($list['data'] as &$v) {
$v['storeInfo'] = $info;
$v['delivery'] = DeliveryModel::where('order_id', $v['order_id'])->find();
}
}
return $list;
@ -399,6 +401,7 @@ class Order extends OrderModel
// $with = ['goods' => ['image', 'goods', 'refund'], 'extract_shop', 'delivery.express'];
$with = ['goods' => ['image', 'refund'], 'extract_shop', 'delivery.express'];
$order = static::getDetail($orderId, $with, $onlyCurrentUser);
// 附加数据
static::related($order, ['address']);
// 该订单是否允许申请售后
@ -460,7 +463,6 @@ class Order extends OrderModel
$order = static::detail($where, $with);
empty($order) && throwError('订单不存在');
//这边后面改成多商户的话需要根据storeid去获取信息
$service = new StoreService;
$info = $service->data();
if (!empty($info['storeInfo'])) {

@ -76,6 +76,7 @@ class InvoiceOrder extends InvoiceOrderModel
$data['source'] = $data['source'] ?? $invoice['source'];
$data['header'] = $data['header'] ?? $invoice['header'];
$data['order_no'] = $order->order_no;
$data['price'] = $order->pay_price;
return $this->save(array_merge($data, [
'user_id' => $userId,
@ -107,4 +108,19 @@ class InvoiceOrder extends InvoiceOrderModel
]) !== false;
}
public function invoicingDel($data) {
if(empty($data['id'])) {
$this->error = '参数异常';
return false;
}
$userId = UserService::getCurrentLoginUserId();
$detail = self::get(['user_id' => $userId, 'id' => $data['id']]);
empty($detail) && throwError('未找到该抬头');
return $detail->delete();
}
}

@ -133,6 +133,7 @@ class Goods extends GoodsService
'categoryId' => $setting['params']['auto']['category'],
'sortType' => $setting['params']['auto']['goodsSort'],
], $setting['params']['auto']['showNum']);
$goodsList = $goodsList ? $goodsList->toArray()['data'] : [];
}
if (empty($goodsList) && $goodsList->isEmpty()) {
return [];

@ -487,6 +487,10 @@ class Goods extends BaseModel
if (isset($param['profit_rate_max']) && $param['profit_rate_max'] !== '') {
$filter[] = ['goods.profit_rate', '<=', $params['profit_rate_max']];
}
if (isset($param['goods_source']) && $param['goods_source'] !== '') {
$filter[] = ['goods.goods_source', '=', $params['goods_source']];
}
// 实例化新查询对象
return $query->where($filter);
}

@ -34,7 +34,7 @@ class Goods extends Controller
// 获取列表记录
$model = new GoodsModel;
$params = $this->request->param();
$params['channel'] = 'zy';
//$params['channel'] = 'zy';
$list= $model->getList($params, (int)$this->request->param('pageSize', 15));
return $this->renderSuccess(compact('list'));
}

Loading…
Cancel
Save