Merge branch 'main' of https://gitea.lihaink.cn/mkm/multi-store
This commit is contained in:
commit
0de65a8ff5
@ -47,7 +47,6 @@ class StoreOrderCartInfoLists extends BaseAdminDataLists implements ListsSearchI
|
||||
return StoreOrderCartInfo::where($this->searchWhere)
|
||||
->field('cart_info,product_id')->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->each(function ($item) {
|
||||
$item['cart_info'] = json_decode($item['cart_info'], true); //将json字符串转换为数组,方便使用其中的数据。
|
||||
$find=StoreBranchProduct::where('id',$item['product_id'])->field('image,store_name')->find();
|
||||
if($find){
|
||||
$item['image']=$find['image'];//商品图片
|
||||
|
@ -28,6 +28,25 @@ class OrderController extends BaseApiController
|
||||
return $this->dataLists(new OrderList());
|
||||
}
|
||||
|
||||
#[
|
||||
ApiDoc\Title('核销码查数据'),
|
||||
ApiDoc\url('/api/order/order/write_code'),
|
||||
ApiDoc\Method('POST'),
|
||||
ApiDoc\Param(name: "code", type: "string", require: false, desc: "核销码"),
|
||||
ApiDoc\NotHeaders(),
|
||||
ApiDoc\Header(name: "token", type: "string", require: true, desc: "token"),
|
||||
ApiDoc\ResponseSuccess("data", type: "array"),
|
||||
]
|
||||
public function write_code()
|
||||
{
|
||||
$code = $this->request->post('code');
|
||||
if(empty($code)){
|
||||
return $this->fail('缺失参数');
|
||||
}
|
||||
$res = OrderLogic::getOne($code);
|
||||
return $this->success('ok',$res);
|
||||
}
|
||||
|
||||
#[
|
||||
ApiDoc\Title('核销订单列表'),
|
||||
ApiDoc\url('/api/order/order/write_list'),
|
||||
@ -402,8 +421,7 @@ class OrderController extends BaseApiController
|
||||
public function writeoff_order()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('check');
|
||||
$userId = $this->request->userId;
|
||||
$res = OrderLogic::writeOff($params,$userId);
|
||||
$res = OrderLogic::writeOff($params);
|
||||
if ($res) {
|
||||
return $this->success('核销成功');
|
||||
}
|
||||
|
@ -436,7 +436,6 @@ class OrderLogic extends BaseLogic
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
* @param $uid
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
@ -444,11 +443,10 @@ class OrderLogic extends BaseLogic
|
||||
* @author: codeliu
|
||||
* @Time: 2024/6/3 22:42
|
||||
*/
|
||||
public static function writeOff($params, $uid): bool
|
||||
public static function writeOff($params): bool
|
||||
{
|
||||
$data = StoreOrder::with('store')->where([
|
||||
'verify_code' => $params['verify_code'],
|
||||
'uid' => $uid
|
||||
'verify_code' => $params['verify_code']
|
||||
])->find();
|
||||
if (empty($data)) {
|
||||
return false;
|
||||
@ -520,6 +518,17 @@ class OrderLogic extends BaseLogic
|
||||
|
||||
}
|
||||
|
||||
public static function getOne($code)
|
||||
{
|
||||
return StoreOrder::with(['store'])->where('verify_code',$code)
|
||||
->select()->each(function ($item) {
|
||||
$item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with('goodsName')->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time')->limit(3)->select();
|
||||
$item['goods_count']=count(explode(',',$item['cart_id']));
|
||||
return $item; //返回处理后的数据。
|
||||
})
|
||||
->toArray();
|
||||
|
||||
}
|
||||
|
||||
public static function write_list($info,$status,$params)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ use app\common\{logic\BaseLogic,
|
||||
model\system_store\SystemStore,
|
||||
model\user\User,
|
||||
model\user\UserRecharge,
|
||||
model\user\UserShip,
|
||||
service\wechat\WeChatMnpService};
|
||||
|
||||
/**
|
||||
@ -59,13 +60,20 @@ class UserLogic extends BaseLogic
|
||||
|
||||
public static function info($uid)
|
||||
{
|
||||
$data = User::where('id',$uid)
|
||||
->field('avatar,real_name,nickname,account,mobile,sex,login_ip,user_money')
|
||||
$data = User::with(['userShip'])->where('id',$uid)
|
||||
->field('avatar,real_name,nickname,account,mobile,sex,login_ip,user_money,total_recharge_amount,user_ship')
|
||||
->find();
|
||||
|
||||
//判断是不是员工
|
||||
if($data){
|
||||
$data = $data->toArray();
|
||||
$all =UserShip::field('id,title,limit')->select()->toArray();
|
||||
$new = self::getNextArrayByID($all,$data['user_ship']);
|
||||
$data['next_level'] = '';
|
||||
$data['next_limit'] = 0;
|
||||
if($new){
|
||||
$data['next_level'] = $new['title'];
|
||||
$data['next_limit'] = $new['limit'] - $data['total_recharge_amount'];
|
||||
}
|
||||
$data['is_staff'] = 0;
|
||||
$data['store_id'] = 0;
|
||||
if(isset($data['mobile']) && $data['mobile']){
|
||||
@ -91,4 +99,22 @@ class UserLogic extends BaseLogic
|
||||
}
|
||||
|
||||
|
||||
public static function getNextArrayByID($arr, $id) {
|
||||
// 遍历数组
|
||||
foreach ($arr as $key => $value) {
|
||||
// 检查当前数组的id是否与传入的id匹配
|
||||
if ($value['id'] == $id) {
|
||||
// 如果当前数组不是最后一个,则返回下一个数组
|
||||
if ($key + 1 < count($arr)) {
|
||||
return $arr[$key + 1];
|
||||
}
|
||||
// 如果当前数组是最后一个,则返回null或空数组
|
||||
return null;
|
||||
}
|
||||
}
|
||||
// 如果没有找到匹配的id,则返回null或空数组
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -34,11 +34,14 @@ class PaymentLogic extends BaseLogic
|
||||
{
|
||||
// 支付编号-仅为微信支付预置(同一商户号下不同客户端支付需使用唯一订单号)
|
||||
$paySn = $order['order_id'];
|
||||
if ($order['pay_price'] == 0) {
|
||||
if ($order['pay_price'] === 0) {
|
||||
PayNotifyLogic::handle($from, $order['order_id']);
|
||||
return ['pay_way' => PayEnum::BALANCE_PAY];
|
||||
}
|
||||
try {
|
||||
if(isset($order['price'])){
|
||||
$order['pay_price'] = $order['price'];
|
||||
}
|
||||
switch ($payWay) {
|
||||
case PayEnum::WECHAT_PAY:
|
||||
$auth = UserAuth::where(['user_id' => $order['uid'], 'terminal' => $terminal])->findOrEmpty();
|
||||
|
@ -21,6 +21,13 @@ class User extends BaseModel
|
||||
protected $deleteTime = 'delete_time';
|
||||
|
||||
|
||||
public function userShip()
|
||||
{
|
||||
return $this->hasOne(UserShip::class,'id','user_ship')
|
||||
// return $this->hasOne(UserShip::class,'user_ship','id')
|
||||
->bind(['vip_name'=>'title','discount','limit']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 关联用户授权模型
|
||||
* @return \think\model\relation\HasOne
|
||||
|
Loading…
x
Reference in New Issue
Block a user