|
|
@@ -18,6 +18,8 @@ namespace app\adminapi\logic\works;
|
|
|
use app\api\logic\PerformanceLogic;
|
|
|
use app\common\enum\worker\WorkerAccountLogEnum;
|
|
|
use app\common\logic\WorkerAccountLogLogic;
|
|
|
+use app\common\model\coupon\CouponCategory;
|
|
|
+use app\common\model\coupon\UserCoupon;
|
|
|
use app\common\model\dict\DictData;
|
|
|
use app\common\model\master_worker\MasterWorker;
|
|
|
use app\common\model\master_worker\MasterWorkerAccountLog;
|
|
|
@@ -521,6 +523,40 @@ class ServiceWorkLogic extends BaseLogic
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ public static function getUserCouponDetails($params)
|
|
|
+ {
|
|
|
+ try{
|
|
|
+ $work = ServiceWork::where('id',$params['id'])->findOrEmpty();
|
|
|
+ if(!$work){
|
|
|
+ throw new \Exception('工单不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ $coupon_all_ids =UserCoupon::where('user_id',$work['user_id'])
|
|
|
+ ->where('voucher_count','>',0)
|
|
|
+ ->where('voucher_status',0)
|
|
|
+ ->where('expire_time','>',time())
|
|
|
+ ->column('coupon_id');
|
|
|
+ $coupon_ids = CouponCategory::where('goods_category_id',$work['goods_category_id'])->whereIn('coupon_id',$coupon_all_ids)->column('coupon_id');
|
|
|
+ $data = UserCoupon::where('user_id',$work['user_id'])
|
|
|
+ ->where('voucher_count','>',0)
|
|
|
+ ->where('voucher_status',0)
|
|
|
+ ->whereIn('coupon_id',$coupon_ids)
|
|
|
+ ->append(['discount_ratio_text'])
|
|
|
+ ->where('expire_time','>',time())
|
|
|
+ ->visible(['id','coupon_id','amount','amount_require','begin_use','discount_ratio','event_name','expire_time','max_deductible_price','server_category_name','mold_type'])
|
|
|
+ ->select()->toArray();
|
|
|
+ foreach($data as $k => $v){
|
|
|
+ $data[$k]['begin_use'] = date("Y-m-d H:i:s",$v['begin_use'] );
|
|
|
+ $data[$k]['expire_time'] = date("Y-m-d H:i:s",$v['expire_time'] );
|
|
|
+ $data[$k]['amount_require'] = '满'.$v['amount_require'].'可用';
|
|
|
+ }
|
|
|
+ return $data;
|
|
|
+ } catch(\Exception $e){
|
|
|
+ self::setError($e->getMessage());
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static function getDetailWorkServiceStatus($params)
|
|
|
{
|
|
|
$result = ServiceWork::where('id',$params['id'])->field('work_status,user_confirm_status,appointment_time,price_approval,appoint_approval')->findOrEmpty()->toArray();
|