init: import production code mss.nahaichuan.com (exclude Runtime/Uploads/backups/logs)
这个提交包含在:
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
namespace CashierApi\Business;
|
||||
|
||||
use Common\Model\RetailGoodsModel;
|
||||
use Common\Model\RetailSkuGoodsModel;
|
||||
|
||||
//[1.7.90]
|
||||
|
||||
/**
|
||||
* 传称类
|
||||
* Class Legend
|
||||
* [
|
||||
* 修改商品的Plus码|价格 modifyGoods
|
||||
* 修改plus码验证 verify
|
||||
* ]
|
||||
* @package CashierApi\Business
|
||||
*/
|
||||
class Legend
|
||||
{
|
||||
/**
|
||||
* 修改Plus码(已弃用)
|
||||
* @param $param
|
||||
* [
|
||||
* store_id
|
||||
* merchant_id
|
||||
* goods_id
|
||||
* sku_id
|
||||
* plu_code
|
||||
* ]
|
||||
* @return mixed
|
||||
*/
|
||||
public function modifyPlu($param)
|
||||
{
|
||||
$verifyResult = $this->verify($param);
|
||||
if ($verifyResult['status'] != 1) {
|
||||
return $verifyResult;
|
||||
}
|
||||
if (!empty($param['sku_id'])) {
|
||||
$where = [
|
||||
'id' => $param['sku_id']
|
||||
];
|
||||
$goodsModel = new RetailSkuGoodsModel();
|
||||
} else {
|
||||
$where = [
|
||||
'id' => $param['goods_id']
|
||||
];
|
||||
$goodsModel = new RetailGoodsModel();
|
||||
}
|
||||
$state = $goodsModel->updateOrder($where, [
|
||||
'plu_code' => $param['plu_code']
|
||||
]);
|
||||
if ($state) {
|
||||
return callBack(statusCode()['success'], "修改成功");
|
||||
} else {
|
||||
return callBack(statusCode()['success'], "暂无修改");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改Plus码
|
||||
* @param $param
|
||||
* [
|
||||
* store_id
|
||||
* merchant_id
|
||||
* modify_type 1修改plus码 2修改价格
|
||||
* goods_id
|
||||
* sku_id
|
||||
* plu_code
|
||||
* retail_price
|
||||
* ]
|
||||
* @return mixed
|
||||
*/
|
||||
public function modifyGoods($param)
|
||||
{
|
||||
$verifyResult = $this->verify($param);
|
||||
if ($verifyResult['status'] != 1) {
|
||||
return $verifyResult;
|
||||
}
|
||||
if (!empty($param['sku_id'])) {
|
||||
$where = [
|
||||
'id' => $param['sku_id']
|
||||
];
|
||||
$goodsModel = new RetailSkuGoodsModel();
|
||||
} else {
|
||||
$where = [
|
||||
'id' => $param['goods_id']
|
||||
];
|
||||
$goodsModel = new RetailGoodsModel();
|
||||
}
|
||||
$param['modify_type'] = $param['modify_type'] ? $param['modify_type'] : 1;
|
||||
switch ($param['modify_type']) {
|
||||
case 1:
|
||||
$data = [
|
||||
'plu_code' => $param['plu_code']
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
$data = [
|
||||
'retail_price' => $param['retail_price']
|
||||
];
|
||||
break;
|
||||
}
|
||||
$state = $goodsModel->updateOrder($where, $data);
|
||||
if ($state) {
|
||||
return callBack(statusCode()['success'], "修改成功");
|
||||
} else {
|
||||
return callBack(statusCode()['success'], "暂无修改");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改plus码验证
|
||||
* @param $param
|
||||
* [
|
||||
* store_id
|
||||
* merchant_id
|
||||
* modify_type 1修改plus码 2修改价格
|
||||
* goods_id
|
||||
* sku_id
|
||||
* plu_code
|
||||
* retail_price 价格
|
||||
* ]
|
||||
* @return mixed
|
||||
*/
|
||||
public function verify($param)
|
||||
{
|
||||
$param['modify_type'] = $param['modify_type'] ? $param['modify_type'] : 1;
|
||||
if (empty($param['merchant_id']) || empty($param['store_id'])) {
|
||||
return callBack(statusCode()['error'], "登录超时");
|
||||
}
|
||||
if (!in_array($param['modify_type'], ['1', '2'])) {
|
||||
return callBack(statusCode()['error'], '修改类型有误');
|
||||
}
|
||||
switch ($param['modify_type']) {
|
||||
case 1:
|
||||
if (empty($param['plu_code']) || !preg_match("/^[1-9]\d{0,3}$/", $param['plu_code'])) {
|
||||
return callBack(statusCode()['error'], "请输入正确的Plu码");
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (empty($param['retail_price']) || !preg_match("/^[0-9]+(.[0-9]{1,2})?$/", $param['retail_price'])) {
|
||||
return callBack(statusCode()['error'], "请输入正确的价格");
|
||||
}
|
||||
break;
|
||||
}
|
||||
return callBack(statusCode()['success'], "验证成功");
|
||||
}
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户