|
|
|
@ -1,15 +1,30 @@ |
|
|
|
|
package com.bweb.controller.ApiMchProduct; |
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.hai.common.exception.ErrorCode; |
|
|
|
|
import com.hai.common.exception.ErrorHelp; |
|
|
|
|
import com.hai.common.exception.SysCode; |
|
|
|
|
import com.hai.common.security.SessionObject; |
|
|
|
|
import com.hai.common.security.UserCenter; |
|
|
|
|
import com.hai.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hai.model.ResponseData; |
|
|
|
|
import com.hai.model.UserInfoModel; |
|
|
|
|
import com.hai.openApi.service.ApiMchProductService; |
|
|
|
|
import com.hai.order.type.OrderProductType; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.slf4j.Logger; |
|
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
|
import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod; |
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
import java.util.Objects; |
|
|
|
|
|
|
|
|
|
@Controller |
|
|
|
|
@RequestMapping(value = "/apiMchProduct") |
|
|
|
@ -24,4 +39,47 @@ public class ApiMchProductController { |
|
|
|
|
@Autowired |
|
|
|
|
private UserCenter userCenter; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/insertMchProduct", method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "新增产品") |
|
|
|
|
public ResponseData insertMchProduct(@RequestBody JSONObject object, HttpServletRequest request) { |
|
|
|
|
try { |
|
|
|
|
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
|
|
if (object == null || |
|
|
|
|
object.getInteger("productType") == null || |
|
|
|
|
object.getString("mchId") == null || |
|
|
|
|
object.getBigDecimal("discount") == null |
|
|
|
|
) { |
|
|
|
|
log.error("ApiProductController -> insertProduct() error!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (Objects.equals(object.getInteger("productType"), OrderProductType.PRODUCT_TYPE6.getNumber())) { |
|
|
|
|
if (object.getLong("companyId") == null || |
|
|
|
|
object.getString("merchantId") == null |
|
|
|
|
) { |
|
|
|
|
log.error("ApiProductController -> insertProduct() error!"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
object.put("operatorId", userInfoModel.getSecUser().getId()); |
|
|
|
|
object.put("operatorName", userInfoModel.getSecUser().getLoginName()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
apiMchProductService.insertMchProduct(object); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("新增成功"); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("ApiProductController --> insertPrice() error!", e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|