|
|
@@ -0,0 +1,183 @@
|
|
|
+package com.uas.platform.b2c.trade.rate.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
+import com.uas.platform.b2c.core.utils.FastjsonUtils;
|
|
|
+import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
+import com.uas.platform.b2c.prod.store.service.StoreInService;
|
|
|
+import com.uas.platform.b2c.trade.order.model.OrderDetail;
|
|
|
+import com.uas.platform.b2c.trade.rate.model.RateBuyer;
|
|
|
+import com.uas.platform.b2c.trade.rate.model.RateGoods;
|
|
|
+import com.uas.platform.b2c.trade.rate.model.RateTemplate;
|
|
|
+import com.uas.platform.b2c.trade.rate.model.RateVendor;
|
|
|
+import com.uas.platform.b2c.trade.rate.service.RateService;
|
|
|
+import com.uas.platform.b2c.trade.support.CodeType;
|
|
|
+import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
+import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.method.P;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 评价接口类
|
|
|
+ * Created by wangdy on 2017-08-30.
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/rate")
|
|
|
+public class RateController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private RateService rateService;
|
|
|
+ @Autowired
|
|
|
+ private StoreInService storeInService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 买家评价卖家店铺
|
|
|
+ *
|
|
|
+ * @param json storeid,enuu,3个星级
|
|
|
+ * @return the result map
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/rateVendor/{orderId}", method = RequestMethod.POST)
|
|
|
+ public ResultMap saveRateVendor(@PathVariable("orderId") Long orderId, @RequestBody String json) {
|
|
|
+ RateVendor rateVendor = FastjsonUtils.fromJson(json, RateVendor.class);
|
|
|
+ rateVendor.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ rateVendor.setUserEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ rateVendor.setOrderId(orderId);
|
|
|
+ rateVendor.setTime(new Date(System.currentTimeMillis()));
|
|
|
+ if(null == rateVendor.getStoreId() || null == rateVendor.getEnuu() || null== rateVendor.getVendorLevel()){
|
|
|
+ return new ResultMap(CodeType.ERROR_STATE.code(),"参数有误");
|
|
|
+ }
|
|
|
+ RateVendor result = rateService.saveRateVendor(rateVendor);
|
|
|
+ //订单状态变更
|
|
|
+ //TODO
|
|
|
+ return new ResultMap(CodeType.OK.code(), "评价成功", result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 买家评价商品
|
|
|
+ *
|
|
|
+ * @param json 匿名,
|
|
|
+ * @return the result map
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/rateGoods/{orderId}", method = RequestMethod.POST)
|
|
|
+ public ResultMap saveRateGoods(@PathVariable("orderId") String orderId, @RequestBody String json) {
|
|
|
+ List<RateGoods> rateGoodsList = FastjsonUtils.fromJsonArray(json, RateGoods.class);
|
|
|
+ for (RateGoods rateGoods : rateGoodsList){
|
|
|
+ //默认匿名评价
|
|
|
+ rateGoods.setIsAnony(rateGoods.getIsAnony() == null ? 1 : rateGoods.getIsAnony());
|
|
|
+ rateGoods.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ rateGoods.setUserEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ rateGoods.setOrderId(orderId);
|
|
|
+ rateGoods.setBuyerRateTime(new Date(System.currentTimeMillis()));
|
|
|
+
|
|
|
+ }
|
|
|
+ rateService.saveRateGoods(rateGoodsList);
|
|
|
+
|
|
|
+ return new ResultMap(CodeType.OK.code(), "评价成功");
|
|
|
+
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 买家追评评价商品
|
|
|
+ *
|
|
|
+ * @param json 匿名,
|
|
|
+ * @return the result map
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/afterRateGoods/{orderId}", method = RequestMethod.POST)
|
|
|
+ public ResultMap saveAfterRateGoods(@PathVariable("orderId") String orderId, @RequestBody String json) {
|
|
|
+ List<RateGoods> rateGoodsList = FastjsonUtils.fromJsonArray(json, RateGoods.class);
|
|
|
+ for (RateGoods rateGoods : rateGoodsList){
|
|
|
+ //默认匿名评价
|
|
|
+ rateGoods.setIsAnony(rateGoods.getIsAnony() == null ? 1 : rateGoods.getIsAnony());
|
|
|
+ rateGoods.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ rateGoods.setUserEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ rateGoods.setOrderId(orderId);
|
|
|
+ rateGoods.setBuyerAfterRateTime(new Date(System.currentTimeMillis()));
|
|
|
+
|
|
|
+ }
|
|
|
+ rateService.saveAfterRateGoods(rateGoodsList);
|
|
|
+
|
|
|
+ return new ResultMap(CodeType.OK.code(), "追评成功");
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卖家评价买家
|
|
|
+ *
|
|
|
+ * @param json 匿名,
|
|
|
+ * @return the result map
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/rateBuyer/{purchaseId}", method = RequestMethod.POST)
|
|
|
+ public ResultMap saveRateBuyer(@PathVariable("purchaseId") String purchaseId, @RequestBody String json) {
|
|
|
+ RateBuyer rateBuyer = FastjsonUtils.fromJson(json, RateBuyer.class);
|
|
|
+ rateBuyer.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ rateBuyer.setUserEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ rateBuyer.setPurchaseId(purchaseId);
|
|
|
+ rateBuyer.setVendorRateTime(new Date(System.currentTimeMillis()));
|
|
|
+ RateBuyer result = rateService.saveRateBuyer(rateBuyer);
|
|
|
+
|
|
|
+ return new ResultMap(CodeType.OK.code(), "评价成功",result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卖家追评价买家
|
|
|
+ *
|
|
|
+ * @param json 匿名,
|
|
|
+ * @return the result map
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/afterRateBuyer/{purchaseId}", method = RequestMethod.POST)
|
|
|
+ public ResultMap saveAfterRateBuyer(@PathVariable("purchaseId") String purchaseId, @RequestBody String json) {
|
|
|
+ RateBuyer rateBuyer = FastjsonUtils.fromJson(json, RateBuyer.class);
|
|
|
+ rateBuyer.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ rateBuyer.setUserEnuu(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ rateBuyer.setPurchaseId(purchaseId);
|
|
|
+ rateBuyer.setVendorRateTime(new Date(System.currentTimeMillis()));
|
|
|
+ RateBuyer result = rateService.saveRateBuyer(rateBuyer);
|
|
|
+
|
|
|
+ return new ResultMap(CodeType.OK.code(), "追评成功",result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存或修改评价模版
|
|
|
+ *
|
|
|
+ * @param json 匿名,
|
|
|
+ * @return the result map
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/rateTemplate/{storeuuid}", method = RequestMethod.POST)
|
|
|
+ public ResultMap saveRateTemplate(@PathVariable("storeuuid") String storeuuid, @RequestBody String json) {
|
|
|
+ RateTemplate rateTemplate = FastjsonUtils.fromJson(json, RateTemplate.class);
|
|
|
+ rateTemplate.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ rateTemplate.setStoreId((storeInService.findByUuid(storeuuid)).getId());
|
|
|
+
|
|
|
+ rateTemplate.setCreateTime(new Date(System.currentTimeMillis()));
|
|
|
+ RateTemplate result = rateService.saveRateTemplate(rateTemplate);
|
|
|
+
|
|
|
+ return new ResultMap(CodeType.OK.code(), "创建成功",result);
|
|
|
+ }
|
|
|
+
|
|
|
+ /***************************查询操作******************************************/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询该企业下的所有模版信息
|
|
|
+ * @param storeuuid
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/rateTemplate/{storeuuid}", method = RequestMethod.GET)
|
|
|
+ public ResultMap getRateTemplate(@PathVariable("storeuuid") String storeuuid){
|
|
|
+ Long storeid = storeInService.findByUuid(storeuuid).getId();
|
|
|
+ List<RateTemplate> result = rateService.getRateTempalteByStoreId(storeid);
|
|
|
+ return new ResultMap(CodeType.OK.code(), "查询成功",result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/rateVendor/{orderId}", method = RequestMethod.GET)
|
|
|
+ public ResultMap getRateVendor(@PathVariable("orderId")String orderId){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|