|
|
@@ -207,35 +207,41 @@ public class WishApi {
|
|
|
String subject = (String)request.getAttribute("subject");
|
|
|
|
|
|
try {
|
|
|
- AddressInfo addressInfo = addressInfoService.get("00000000-0000-0000-0000-000000000000");
|
|
|
-
|
|
|
WishInfo wishInfo = wishInfoService.get(wishInfoId);
|
|
|
- wishInfo.setRemainingAmount(wishInfo.getRemainingAmount() - 1);
|
|
|
- wishInfoService.update(wishInfo);
|
|
|
-
|
|
|
- WishInfoUserRecord wishInfoUserRecord = new WishInfoUserRecord();
|
|
|
- wishInfoUserRecord.setId(UUID.randomUUID().toString());
|
|
|
- wishInfoUserRecord.setRegUserId(subject);
|
|
|
- wishInfoUserRecord.setWishInfoId(wishInfoId);
|
|
|
- wishInfoUserRecord.setStudentAspirationsId(studentAspirationsId);
|
|
|
- wishInfoUserRecord.setIsSpot(isSpot);
|
|
|
- wishInfoUserRecord.setStatus("0");
|
|
|
- wishInfoUserRecord.setNum(getSerialNumber());
|
|
|
- wishInfoUserRecord.setSender(addressInfo.getRecipients());
|
|
|
- wishInfoUserRecord.setSenderPhone(addressInfo.getPhone());
|
|
|
- wishInfoUserRecord.setSenderAddress(addressInfo.getRegion() + addressInfo.getDetailAddress());
|
|
|
- wishInfoUserRecord.setRecipients (recipients);
|
|
|
- wishInfoUserRecord.setRecipientsPhone(recipientsPhone);
|
|
|
- wishInfoUserRecord.setRecipientsAddress(recipientsRegion + recipientsAddress);
|
|
|
- wishInfoUserRecord.setDelFlag(false);
|
|
|
- wishInfoUserRecord.setCreateBy(subject);
|
|
|
- wishInfoUserRecord.setCreateTime(new Date());
|
|
|
- wishInfoUserRecordService.insert(wishInfoUserRecord);
|
|
|
-
|
|
|
- setAddress(recipients, recipientsPhone, recipientsRegion, recipientsAddress, request);
|
|
|
+ if(wishInfo.getRemainingAmount() > 0) {
|
|
|
+ wishInfo.setRemainingAmount(wishInfo.getRemainingAmount() - 1);
|
|
|
+ wishInfoService.update(wishInfo);
|
|
|
+
|
|
|
+ AddressInfo addressInfo = addressInfoService.get("00000000-0000-0000-0000-000000000000");
|
|
|
+
|
|
|
+ WishInfoUserRecord wishInfoUserRecord = new WishInfoUserRecord();
|
|
|
+ wishInfoUserRecord.setId(UUID.randomUUID().toString());
|
|
|
+ wishInfoUserRecord.setRegUserId(subject);
|
|
|
+ wishInfoUserRecord.setWishInfoId(wishInfoId);
|
|
|
+ wishInfoUserRecord.setStudentAspirationsId(studentAspirationsId);
|
|
|
+ wishInfoUserRecord.setIsSpot(isSpot);
|
|
|
+ wishInfoUserRecord.setStatus("0");
|
|
|
+ wishInfoUserRecord.setNum(getSerialNumber());
|
|
|
+ wishInfoUserRecord.setSender(addressInfo.getRecipients());
|
|
|
+ wishInfoUserRecord.setSenderPhone(addressInfo.getPhone());
|
|
|
+ wishInfoUserRecord.setSenderAddress(addressInfo.getRegion() + addressInfo.getDetailAddress());
|
|
|
+ wishInfoUserRecord.setRecipients(recipients);
|
|
|
+ wishInfoUserRecord.setRecipientsPhone(recipientsPhone);
|
|
|
+ wishInfoUserRecord.setRecipientsAddress(recipientsRegion + recipientsAddress);
|
|
|
+ wishInfoUserRecord.setDelFlag(false);
|
|
|
+ wishInfoUserRecord.setCreateBy(subject);
|
|
|
+ wishInfoUserRecord.setCreateTime(new Date());
|
|
|
+ wishInfoUserRecordService.insert(wishInfoUserRecord);
|
|
|
+
|
|
|
+ setAddress(recipients, recipientsPhone, recipientsRegion, recipientsAddress, request);
|
|
|
|
|
|
- msgResult.setResult(true);
|
|
|
- msgResult.setData(wishInfoUserRecord.getId());
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(wishInfoUserRecord.getId());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("提交失败,已无可供交换商品。");
|
|
|
+ }
|
|
|
}
|
|
|
catch(Exception ex){
|
|
|
logger.error(ex.getMessage(),ex);
|