package com.dsh.activity.controller; import com.dsh.activity.entity.THuiminRecord; import com.dsh.activity.entity.TPayHuimin; import com.dsh.activity.entity.VipDetail; import com.dsh.activity.feignclient.other.SiteClient; import com.dsh.activity.feignclient.other.StoreClient; import com.dsh.activity.feignclient.other.model.Site; import com.dsh.activity.feignclient.other.model.Store; import com.dsh.activity.service.*; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; import java.util.Date; import java.util.List; /** * 硬件方调用 存储玩湃惠民卡使用记录 * @author zhibing.pu * @date 2023/6/24 11:27 */ @RestController @RequestMapping("/base/huimin") public class HuiminRecordController { @Resource private HuiminRecordService huiminRecordService; @Resource private PayHuiminService payHuiminService; @Resource private VipDetailService vipDetailService; @Resource private SiteClient siteClient; @Resource private StoreClient storeClient; /** * 硬件开门后回调 存储玩湃惠民卡使用记录 */ @PostMapping("/record") public void aliPayHuiminCallback(Integer id,Integer uid) { System.err.println("硬件开门后回调 存储玩湃惠民卡使用记录"); System.err.println("id:"+id); System.err.println("uid:"+uid); if (id!=null){ THuiminRecord huiminRecord = new THuiminRecord(); TPayHuimin payHuimin = payHuiminService.getById(id); huiminRecord.setPayId(id); huiminRecord.setHuiminCardId(payHuimin.getCardId()); huiminRecord.setInsertTime(new Date()); huiminRecord.setAppUserId(uid); huiminRecordService.save(huiminRecord); } } /** * 硬件开门后回调 存储会员使用明细 */ @GetMapping("/recordVipDetail") public void recordVipDetail(Integer vipDetail,Integer rid,Integer sid) throws ParseException { System.err.println("硬件开门后回调 存储会员卡门票权益使用记录"); System.err.println("vipDetailId:"+vipDetail); System.err.println("rid:"+rid); System.err.println("sid:"+sid); String replace = vipDetail.toString().replace("-", ""); VipDetail vipDetailServiceById = vipDetailService.getById(Integer.valueOf( replace)); if (vipDetailServiceById!=null){ Site site = siteClient.querySiteById(rid); if (site!=null){ List stores = storeClient.queryStoreByIds(Arrays.asList(sid)); if (!stores.isEmpty()){ Store store = stores.get(0); if(store.getOperatorId()==null){ vipDetailServiceById.setOperatorId(0); }else{ vipDetailServiceById.setOperatorId(store.getOperatorId()); } } } // 根据场地id查询运营商id vipDetailServiceById.setUseSiteId(rid); vipDetailServiceById.setUseStoreId(sid); vipDetailServiceById.setStatus(2); vipDetailServiceById.setStartTime(new Date()); vipDetailServiceById.setUseTime(new Date()); // 获取今天的晚上23:59:59 // 获取今天的晚上23:59:59 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); String endOfDayStr = today + " 23:59:58"; Date endOfDay = sdf.parse(endOfDayStr); vipDetailServiceById.setEndTime(endOfDay); vipDetailService.updateById(vipDetailServiceById); } } }