$params['merchant'], 'store_id' => $params['store_id'], 'uid' => $params['uid'], 'number' => $params['number'], 'total' => $params['total'], 'deduction_price' => $params['deduction_price'], 'actual' => $params['actual'], 'money' => $params['money'], 'pay_type' => $params['pay_type'], 'data' => $params['data'], 'type' => $params['type'], 'more' => $params['more'] ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑零售订单 * @param array $params * @return bool * @author likeadmin * @date 2024/04/24 09:57 */ public static function edit(array $params): bool { Db::startTrans(); try { Cashierclass::where('id', $params['id'])->update([ 'merchant' => $params['merchant'], 'store_id' => $params['store_id'], 'uid' => $params['uid'], 'number' => $params['number'], 'total' => $params['total'], 'deduction_price' => $params['deduction_price'], 'actual' => $params['actual'], 'money' => $params['money'], 'pay_type' => $params['pay_type'], 'data' => $params['data'], 'type' => $params['type'], 'more' => $params['more'] ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 审核零售订单 * @param array $params * @return bool * @author likeadmin * @date 2024/04/24 09:57 */ public static function auditing(array $params,$admin_id): bool { $data = Cashierclass::where('id',$params['id'])->findOrEmpty(); if($data->isEmpty()){ self::setError('订单信息不存在'); return false; } if($data->type != 0){ self::setError('此订单已审核'); return false; } Db::startTrans(); try { Cashierclass::where('id', $params['id'])->update([ 'type' => 1, 'auditinguser' => $admin_id, 'auditingtime' => time() ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除零售订单 * @param array $params * @return bool * @author likeadmin * @date 2024/04/24 09:57 */ public static function delete(array $params): bool { return Cashierclass::destroy($params['id']); } /** * @notes 获取零售订单详情 * @param $params * @return array * @author likeadmin * @date 2024/04/24 09:57 */ public static function detail($params): array { $find=Cashierclass::where($params)->findOrEmpty()->toArray(); if($find){ $find['goods_list']= Cashierinfo::where('pid',$find['id']) ->with('goodsName') ->field('goods,price sell,nums')->select()->each(function($item){ $item['msg']='预计48小时发货'; $item['unit_name']=Unit::where('id',$item['unit'])->value('name'); }); $merchant=Merchant::where('mer_id',$find['merchant'])->field('mer_id,uid,mer_name,service_phone,mer_address')->find(); $merchant['real_name']=User::where('id',$merchant['uid'])->value('real_name'); $find['merchant_info']=$merchant; } return $find; } /** * 打印 */ public static function prints($id){ $find = Cashierclass::where('id', $id)->field('id,merchant,real_name,user_phone,user_address,uid,number,total,actual,create_time')->find(); if ($find) { $merchant = Merchant::where('mer_id', $find['merchant'])->field('mer_name,uid,service_phone')->find(); $mer_user_info = User::where('id', $merchant['uid'])->field('real_name,mobile')->find(); $user = User::where('id', $find['uid'])->field('nickname,mobile')->find(); $find['mer_name'] = $merchant['mer_name']; $find['mer_phone'] = $merchant['service_phone']; $find['mer_nickname'] = $mer_user_info['real_name']; $find['mer_user_mobile'] = $mer_user_info['mobile']; $find['nickname'] = $user['nickname']; $find['user_mobile'] = $user['mobile']; $find['info'] = Cashierinfo::where('pid', $find['id'])->field('goods,nums,price,total')->select()->each(function ($item) { $goods = Goods::where('id', $item['goods'])->field('name,unit')->find(); $item['unit_name'] = Unit::where('id', $goods['unit'])->value('name'); $item['goods_name'] = $goods['name']; return $item; }); return $find; }else{ self::setError('订单不存在'); return false; } } }