|
|
@ -7,6 +7,7 @@ import com.github.pagehelper.PageInfo; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
import com.hai.config.PayloService; |
|
|
|
import com.hai.config.PayloService; |
|
|
|
import com.hai.config.PetroConfig; |
|
|
|
import com.hai.config.PetroConfig; |
|
|
|
|
|
|
|
import com.hai.config.PetroCouponConfig; |
|
|
|
import com.hai.entity.ApiCoupon; |
|
|
|
import com.hai.entity.ApiCoupon; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.model.ResponseData; |
|
|
|
import com.hai.openApi.service.ApiBlxCouponService; |
|
|
|
import com.hai.openApi.service.ApiBlxCouponService; |
|
|
@ -22,8 +23,11 @@ import org.springframework.web.bind.annotation.RequestParam; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
@Controller |
|
|
|
@RequestMapping(value = "/apiCoupon") |
|
|
|
@RequestMapping(value = "/apiCoupon") |
|
|
@ -64,62 +68,81 @@ public class ApiCouponController { |
|
|
|
public ResponseData synCouponRule(@RequestParam(name = "type", required = true) Integer type) { |
|
|
|
public ResponseData synCouponRule(@RequestParam(name = "type", required = true) Integer type) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == 4) { |
|
|
|
PetroConfig.init(type); |
|
|
|
JSONObject jsonObject = PetroCouponConfig.getCouponList(); |
|
|
|
|
|
|
|
JSONArray array = jsonObject.getJSONArray("data"); |
|
|
|
JSONObject jsonObject = petroConfig.synCouponRule(); |
|
|
|
List<JSONObject> list = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
if (jsonObject.getString("resultCode").equals("0000")) { |
|
|
|
for (int i = 0; i < array.size(); i++) { |
|
|
|
String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); |
|
|
|
JSONObject object = array.getJSONObject(i); |
|
|
|
JSONArray jsonArray = JSONArray.parseArray(data); |
|
|
|
object.put("alias" , object.getString("reqCode")); |
|
|
|
|
|
|
|
object.put("title" , object.getString("tplName")); |
|
|
|
System.out.println(jsonArray); |
|
|
|
object.put("qty" , object.getString("ticketBalance")); |
|
|
|
ApiCoupon apiCoupon; |
|
|
|
object.put("faceValue" , object.getBigDecimal("tplAmount").divide(new BigDecimal(100))); |
|
|
|
|
|
|
|
object.put("bizTypeDesc" , "汽油券"); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
object.put("validDate" , "180"); |
|
|
|
|
|
|
|
list.add(object); |
|
|
|
JSONObject object = jsonArray.getJSONObject(i); |
|
|
|
} |
|
|
|
apiCoupon = apiCouponService.findCoupon(object.getString("alias")); |
|
|
|
return ResponseMsgUtil.success(list); |
|
|
|
|
|
|
|
|
|
|
|
if (apiCoupon == null ) { |
|
|
|
} else { |
|
|
|
apiCoupon = new ApiCoupon(); |
|
|
|
PetroConfig.init(type); |
|
|
|
apiCoupon.setCode(object.getString("alias")); |
|
|
|
|
|
|
|
apiCoupon.setDesc(object.getString("declare")); |
|
|
|
JSONObject jsonObject = petroConfig.synCouponRule(); |
|
|
|
apiCoupon.setGoodsType(object.getString("bizType")); |
|
|
|
|
|
|
|
apiCoupon.setName(object.getString("title")); |
|
|
|
if (jsonObject.getString("resultCode").equals("0000")) { |
|
|
|
apiCoupon.setValidType(object.getInteger("validType")); |
|
|
|
String data = PetroConfig.decrypt(jsonObject.getString("jsonResult")); |
|
|
|
if (object.getInteger("validType") == 1) { |
|
|
|
JSONArray jsonArray = JSONArray.parseArray(data); |
|
|
|
apiCoupon.setValidDate(object.getDate("validDate")); |
|
|
|
|
|
|
|
} |
|
|
|
ApiCoupon apiCoupon; |
|
|
|
apiCoupon.setEffectiveDays(object.getInteger("validDate")); |
|
|
|
|
|
|
|
apiCoupon.setImg(object.getString("img")); |
|
|
|
for (int i = 0; i < jsonArray.size(); i++) { |
|
|
|
apiCoupon.setCreateTime(new Date()); |
|
|
|
|
|
|
|
apiCoupon.setUpdateTime(new Date()); |
|
|
|
JSONObject object = jsonArray.getJSONObject(i); |
|
|
|
apiCoupon.setStatus(1); |
|
|
|
apiCoupon = apiCouponService.findCoupon(object.getString("alias")); |
|
|
|
apiCoupon.setType(type); |
|
|
|
|
|
|
|
apiCoupon.setPrice(object.getInteger("faceValue")); |
|
|
|
if (apiCoupon == null ) { |
|
|
|
apiCouponService.insertCoupon(apiCoupon); |
|
|
|
apiCoupon = new ApiCoupon(); |
|
|
|
} else { |
|
|
|
apiCoupon.setCode(object.getString("alias")); |
|
|
|
apiCoupon.setCode(object.getString("alias")); |
|
|
|
apiCoupon.setDesc(object.getString("declare")); |
|
|
|
apiCoupon.setDesc(object.getString("declare")); |
|
|
|
apiCoupon.setGoodsType(object.getString("bizType")); |
|
|
|
apiCoupon.setGoodsType(object.getString("bizType")); |
|
|
|
apiCoupon.setName(object.getString("title")); |
|
|
|
apiCoupon.setName(object.getString("title")); |
|
|
|
apiCoupon.setValidType(object.getInteger("validType")); |
|
|
|
apiCoupon.setValidType(object.getInteger("validType")); |
|
|
|
if (object.getInteger("validType") == 1) { |
|
|
|
if (object.getInteger("validType") == 1) { |
|
|
|
apiCoupon.setValidDate(object.getDate("validDate")); |
|
|
|
apiCoupon.setValidDate(object.getDate("validDate")); |
|
|
|
} |
|
|
|
|
|
|
|
apiCoupon.setEffectiveDays(object.getInteger("validDate")); |
|
|
|
|
|
|
|
apiCoupon.setImg(object.getString("img")); |
|
|
|
|
|
|
|
apiCoupon.setCreateTime(new Date()); |
|
|
|
|
|
|
|
apiCoupon.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
apiCoupon.setStatus(1); |
|
|
|
|
|
|
|
apiCoupon.setType(type); |
|
|
|
|
|
|
|
apiCoupon.setPrice(object.getInteger("faceValue")); |
|
|
|
|
|
|
|
apiCouponService.insertCoupon(apiCoupon); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
apiCoupon.setCode(object.getString("alias")); |
|
|
|
|
|
|
|
apiCoupon.setDesc(object.getString("declare")); |
|
|
|
|
|
|
|
apiCoupon.setGoodsType(object.getString("bizType")); |
|
|
|
|
|
|
|
apiCoupon.setName(object.getString("title")); |
|
|
|
|
|
|
|
apiCoupon.setValidType(object.getInteger("validType")); |
|
|
|
|
|
|
|
if (object.getInteger("validType") == 1) { |
|
|
|
|
|
|
|
apiCoupon.setValidDate(object.getDate("validDate")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
apiCoupon.setEffectiveDays(object.getInteger("validDate")); |
|
|
|
|
|
|
|
apiCoupon.setImg(object.getString("img")); |
|
|
|
|
|
|
|
apiCoupon.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
apiCoupon.setStatus(1); |
|
|
|
|
|
|
|
apiCoupon.setType(type); |
|
|
|
|
|
|
|
apiCoupon.setPrice(object.getInteger("faceValue")); |
|
|
|
|
|
|
|
apiCouponService.editCoupon(apiCoupon); |
|
|
|
} |
|
|
|
} |
|
|
|
apiCoupon.setEffectiveDays(object.getInteger("validDate")); |
|
|
|
|
|
|
|
apiCoupon.setImg(object.getString("img")); |
|
|
|
|
|
|
|
apiCoupon.setUpdateTime(new Date()); |
|
|
|
|
|
|
|
apiCoupon.setStatus(1); |
|
|
|
|
|
|
|
apiCoupon.setType(type); |
|
|
|
|
|
|
|
apiCoupon.setPrice(object.getInteger("faceValue")); |
|
|
|
|
|
|
|
apiCouponService.editCoupon(apiCoupon); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success(jsonArray); |
|
|
|
return ResponseMsgUtil.success(jsonArray); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return ResponseMsgUtil.success("请求失败"); |
|
|
|
return ResponseMsgUtil.success("请求失败"); |
|
|
|
|
|
|
|
|
|
|
|