Compare commits
10 Commits
20250805-0
...
20250806-0
| Author | SHA1 | Date | |
|---|---|---|---|
| f898de515a | |||
| 058b56a348 | |||
| 42dd168c14 | |||
| 4f862caa0b | |||
| ec60074298 | |||
| 006821188d | |||
| 46a305ffe5 | |||
| 5bacdc8585 | |||
| 573aeee8db | |||
| 89797d5bfc |
@@ -56,10 +56,10 @@ class ApiReturnAspect extends AbstractAspect
|
||||
$this->writeResponseLog(json_encode($result));
|
||||
|
||||
//正式服加密 测试服不做处理
|
||||
if (SystemUtil::checkProEnv()) {
|
||||
$cryptoFactory = $this->CryptoFactory->cryptoClass('api', json_encode($result['data']));
|
||||
$result['data'] = $cryptoFactory->encrypt();
|
||||
}
|
||||
// if (SystemUtil::checkProEnv()) {
|
||||
// $cryptoFactory = $this->CryptoFactory->cryptoClass('api', json_encode($result['data']));
|
||||
// $result['data'] = $cryptoFactory->encrypt();
|
||||
// }
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ class GoodCache
|
||||
$imageList = $this->getOssObjects(array_merge($spuImage,$imageIdArr));
|
||||
|
||||
$chefIds = array_column($skuList,'chef_id');
|
||||
$chefList = $this->adminUserModel->getDataByIds($chefIds);
|
||||
$chefList = $this->adminUserModel->getChefNameByIds($chefIds);
|
||||
|
||||
$skuListArr = [];
|
||||
$imageArr = [];
|
||||
|
||||
@@ -107,6 +107,32 @@ class AdminUser extends Model
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
* @return array
|
||||
*/
|
||||
public function getChefNameByIds(array $ids): array
|
||||
{
|
||||
$data = $this
|
||||
->join('chef', function ($join) use ($ids) {
|
||||
$join->on('chef.user_id', '=', 'admin_user.id')
|
||||
->whereIn('chef.id', $ids)
|
||||
->where('admin_user.is_del',UserCode::IS_NO_DEL)
|
||||
->select([
|
||||
'admin_user.chinese_name',
|
||||
'chef.id',
|
||||
'admin_user.username',
|
||||
]);
|
||||
})
|
||||
->get();
|
||||
|
||||
if ($data->isEmpty()) return [];
|
||||
|
||||
$data = $data->toArray();
|
||||
|
||||
return array_column($data,null,'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $ids
|
||||
* @return array
|
||||
|
||||
@@ -92,7 +92,7 @@ class PrintService extends CateringBaseService
|
||||
*/
|
||||
public function cancel(): array
|
||||
{
|
||||
$service = $this->printOrderFactory->handle($this->request->input('type'));
|
||||
$service = $this->printOrderFactory->handle((int)$this->request->input('type'));
|
||||
$service->printId = (int)$this->request->input('print_id');
|
||||
$service->handle();
|
||||
$service->printCancel();
|
||||
|
||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
namespace App\Service\Admin\Catering\Print;
|
||||
|
||||
use App\Exception\ErrException;
|
||||
use App\Lib\Log;
|
||||
use App\Lib\Print\YlyBasicsLib;
|
||||
use App\Model\Printer;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -58,6 +59,12 @@ class YlyPrintService implements PrintOrderInterface
|
||||
#[Inject]
|
||||
protected Printer $printerModel;
|
||||
|
||||
/**
|
||||
* @var Log
|
||||
*/
|
||||
#[Inject]
|
||||
private Log $log;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
@@ -108,9 +115,12 @@ class YlyPrintService implements PrintOrderInterface
|
||||
empty($this->data['order_sno']) ||
|
||||
empty($this->data['username']) ||
|
||||
empty($this->data['mobile']) ||
|
||||
empty($this->data['date']) ||
|
||||
empty($this->data['heapsort'])
|
||||
) throw new ErrException('打印数据丢失');
|
||||
empty($this->data['date'])
|
||||
// empty($this->data['heapsort'])
|
||||
) {
|
||||
$this->log->error('打印数据'.json_encode($this->data));
|
||||
throw new ErrException('打印数据丢失');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,9 +136,6 @@ class YlyPrintService implements PrintOrderInterface
|
||||
//设置宽度
|
||||
$this->content .= "<PW>048</PW>";
|
||||
|
||||
$this->content .= "\n";
|
||||
$this->content .= "\n";
|
||||
|
||||
//取餐号
|
||||
$this->content .= "<FS3><CA>{$this->data['pickup_code']}</CA></FS3>\n";
|
||||
|
||||
@@ -190,7 +197,7 @@ class YlyPrintService implements PrintOrderInterface
|
||||
$contentEdibleTimeTips = config('print.yly.content_edible_time_tips');
|
||||
$this->content .= "<LR2>保质期,$contentEdibleTimeTips</LR2>";
|
||||
|
||||
$this->content .= "<FS3><CA>{$this->data['heapsort']}</CA></FS3>";
|
||||
$this->content .= "<FS3><CA>{$this->data['pickup_code']}</CA></FS3>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,6 +238,8 @@ class YlyPrintService implements PrintOrderInterface
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
private function checkBoxLabelData(): void
|
||||
{
|
||||
@@ -244,7 +253,10 @@ class YlyPrintService implements PrintOrderInterface
|
||||
empty($this->data['driver_name']) ||
|
||||
empty($this->data['current_num']) ||
|
||||
empty($this->data['date_text'])
|
||||
) throw new ErrException('打印数据丢失');
|
||||
) {
|
||||
$this->log->error('打印数据'.json_encode($this->data));
|
||||
throw new ErrException('打印数据丢失-01');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ use App\Model\CouponTemplate;
|
||||
use App\Model\UserCoupon;
|
||||
use App\Service\Api\BaseService;
|
||||
use App\Service\ServiceTrait\Admin\Catering\PrintTrait;
|
||||
use App\Service\ServiceTrait\Api\CouponTrait;
|
||||
use App\Service\ServiceTrait\Api\OrderTrait;
|
||||
use App\Service\ServiceTrait\Common\CycleTrait;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -24,7 +25,7 @@ use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
abstract class BaseOrderService extends BaseService
|
||||
{
|
||||
use CycleTrait,OrderTrait,PrintTrait;
|
||||
use CycleTrait,OrderTrait,PrintTrait,CouponTrait;
|
||||
|
||||
/**
|
||||
* @var int 周期id
|
||||
@@ -100,7 +101,7 @@ abstract class BaseOrderService extends BaseService
|
||||
* 优惠券id
|
||||
* @var int
|
||||
*/
|
||||
protected int $couponId;
|
||||
protected int $couponId = 0;
|
||||
|
||||
/**
|
||||
* 地点id
|
||||
|
||||
@@ -121,6 +121,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
* @return void
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ErrException
|
||||
*/
|
||||
private function placeOrder(): void
|
||||
{
|
||||
@@ -133,12 +134,16 @@ class PlaceOrderService extends BaseOrderService
|
||||
|
||||
$this->insertOrderGoods();
|
||||
|
||||
$this->couponLock();
|
||||
|
||||
Db::commit();
|
||||
} catch (Exception $e){
|
||||
echo $e->getMessage();
|
||||
//回滚数据库 和 缓存
|
||||
Db::rollBack();
|
||||
$this->rollbackStock();
|
||||
|
||||
// $this->rollbackCouponLock();
|
||||
//意外抛出
|
||||
throw new ErrException($e->getMessage());
|
||||
}
|
||||
@@ -207,7 +212,7 @@ class PlaceOrderService extends BaseOrderService
|
||||
$orderInsertModel->is_refund_all = OrderCode::REFUND_NULL;
|
||||
$orderInsertModel->order_json = json_encode($this->orderRes);
|
||||
|
||||
if (!$orderInsertModel->save()) throw new Exception('下单失败');
|
||||
if (!$orderInsertModel->save()) throw new Exception('下单失败-01');
|
||||
|
||||
$this->orderId = $orderInsertModel->id;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
namespace App\Service\Api\System;
|
||||
|
||||
use App\Cache\Redis\Api\SiteCache;
|
||||
use App\Constants\Common\SiteCode;
|
||||
use App\Extend\SystemUtil;
|
||||
use App\Model\Site;
|
||||
use App\Service\Api\BaseService;
|
||||
@@ -36,6 +37,7 @@ class SiteListService extends BaseService
|
||||
$query->where('name', 'like', "%$name%");
|
||||
})
|
||||
// ->where('name', 'like', '%'.$this->request->input('search_value').'%')
|
||||
->where('is_del',SiteCode::SITE_NO_DEL)
|
||||
->paginate($limit)
|
||||
->toArray();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Service\ServiceTrait\Api;
|
||||
|
||||
use App\Constants\Common\CouponCode;
|
||||
use App\Constants\Common\OrderCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Extend\DateUtil;
|
||||
use App\Model\UserCoupon;
|
||||
use Exception;
|
||||
@@ -40,6 +41,46 @@ trait CouponTrait
|
||||
if (!$couponInfo->save()) throw new Exception('CancelOrderConsumer:error:couponStatusUpdateError:'.json_encode($orderInfo->toArray()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function couponLock(): void
|
||||
{
|
||||
if ($this->couponId <= 0) return;
|
||||
|
||||
$couponInfo = $this->userCouponModel->where('id', $this->couponId)->where('user_id',$this->userId)->first();
|
||||
|
||||
if (empty($couponInfo)) return;
|
||||
|
||||
$couponInfo->status = CouponCode::COUPON_STATUS_USED;
|
||||
$couponInfo->use_time = date('Y-m-d H:i:s');
|
||||
|
||||
if (date('Y-m-d H:i:s') > $couponInfo->validity_end_time) throw new Exception('优惠券已过期');
|
||||
|
||||
if (!$couponInfo->save()) throw new Exception('couponLock:error:couponLockUpdateError:'.json_encode($couponInfo->toArray()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws ErrException
|
||||
*/
|
||||
protected function rollbackCouponLock(): void
|
||||
{
|
||||
if ($this->couponId <= 0) return;
|
||||
|
||||
$couponInfo = $this->userCouponModel->where('id', $this->couponId)->where('user_id',$this->userId)->first();
|
||||
|
||||
if (empty($couponInfo)) return;
|
||||
|
||||
if ($couponInfo->status != CouponCode::COUPON_STATUS_USED) return;
|
||||
|
||||
$couponInfo->status = CouponCode::COUPON_STATUS_UNUSED;
|
||||
$couponInfo->use_time = '1970-01-01 00:00:00';
|
||||
|
||||
if (!$couponInfo->save()) throw new ErrException('系统错误-rollback_coupon失败');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $type
|
||||
* @param string $value
|
||||
|
||||
Reference in New Issue
Block a user