diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..d26beaf --- /dev/null +++ b/pom.xml @@ -0,0 +1,155 @@ + + + 4.0.0 + + com.dreawer + shopcenter + 0.0.1-SNAPSHOT + jar + + shopcenter + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 1.5.13.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + Dalston.SR1 + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.boot + spring-boot-starter-jdbc + + + org.springframework.boot + spring-boot-starter-web + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 1.3.2 + + + org.springframework.cloud + spring-cloud-starter-config + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + mysql + mysql-connector-java + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + src/main/java + + **/**/*.properties + **/*.xml + + false + + + src/main/resources + + + + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + + spring-snapshots + Spring Snapshots + https://repo.spring.io/snapshot + + true + + + + spring-milestones + Spring Milestones + https://repo.spring.io/milestone + + false + + + + + + releases + Nexus-releases-repositories + http://172.16.138.103:8081/repository/maven-releases/ + + + snapshots + Nexus-snapshots-repositories + http://172.16.138.103:8081/repository/maven-snapshots/ + + + + + diff --git a/src/main/java/com/dreawer/shopcenter/ShopcenterApplication.java b/src/main/java/com/dreawer/shopcenter/ShopcenterApplication.java new file mode 100644 index 0000000..b665d8f --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/ShopcenterApplication.java @@ -0,0 +1,12 @@ +package com.dreawer.shopcenter; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class ShopcenterApplication { + + public static void main(String[] args) { + SpringApplication.run(ShopcenterApplication.class, args); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/domain/Address.java b/src/main/java/com/dreawer/shopcenter/domain/Address.java new file mode 100644 index 0000000..d82ed04 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/Address.java @@ -0,0 +1,129 @@ +package com.dreawer.shopcenter.domain; + +import com.dreawer.dream.domain.BaseDomain; +import com.dreawer.user.domain.User; + +import java.sql.Timestamp; + +/** + * Address + * 地址实体类 + * @author fenrir + * @Date 17-12-25 + */ +public class Address extends BaseDomain{ + + private static final long serialVersionUID = -3040562912070693905L; + + private String consignee = null; + + private String contact = null; + + private String shippingAddress = null; + + private String address = null; + + private String postcode = null; + + private Boolean isDefault = null; + + private String storeId = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + private User creater = null; // 创建者 + + private Timestamp createTime = null; // 创建时间 + + private User updater = null; // 更新者 + + private Timestamp updateTime = null; // 更新时间 + + public User getCreater() { + return creater; + } + + public void setCreater(User creater) { + this.creater = creater; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public User getUpdater() { + return updater; + } + + public void setUpdater(User updater) { + this.updater = updater; + } + + public Timestamp getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + } + + public Boolean getIsDefault() { + return isDefault; + } + + public void setIsDefault(Boolean isDefault) { + this.isDefault = isDefault; + } + + public String getConsignee() { + return consignee; + } + + public void setConsignee(String consignee) { + this.consignee = consignee; + } + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public String getShippingAddress() { + return shippingAddress; + } + + public void setShippingAddress(String shippingAddress) { + this.shippingAddress = shippingAddress; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPostcode() { + return postcode; + } + + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + +} diff --git a/src/main/java/com/dreawer/shopcenter/domain/Address.mbm.xml b/src/main/java/com/dreawer/shopcenter/domain/Address.mbm.xml new file mode 100644 index 0000000..5cb67a5 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/Address.mbm.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + INSERT INTO + ret_adres(id,consignee,contact,ship_adres,adres,postcode,is_def,sto_id,crer_id,cre_tim) + VALUES (#{id},#{consignee},#{contact},#{shippingAddress},#{address},#{postcode},#{isDefault},#{storeId},#{creater.id},#{createTime}) + + + + + + + + DELETE FROM + ret_adres + WHERE + id = #{id} + + + + + + + + + UPDATE + ret_adres + SET + consignee = #{consignee}, + contact = #{contact}, + ship_adres = #{shippingAddress}, + adres = #{address}, + postcode = #{postcode}, + updr_id = #{updater.id}, + upd_tim = #{updateTime} + WHERE + id = #{id} + AND sto_id = #{storeId} + + + + + + UPDATE ret_adres + SET is_def = CASE id + WHEN #{id} THEN 1 + ELSE 0 + END + WHERE id IN (SELECT t1.id FROM (SELECT * FROM ret_adres ) AS t1 WHERE t1.sto_id = #{storeId}) + + + + + + + + + + + + + + + + + + + + id,consignee,contact,ship_adres,adres,postcode,is_def,sto_id,crer_id,cre_tim + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/dreawer/shopcenter/domain/BusinessLicense.java b/src/main/java/com/dreawer/shopcenter/domain/BusinessLicense.java new file mode 100644 index 0000000..3087e7f --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/BusinessLicense.java @@ -0,0 +1,142 @@ +package com.dreawer.shopcenter.domain; + +import com.dreawer.dream.domain.BaseDomain; +import com.dreawer.user.domain.User; + +import java.sql.Timestamp; + + +public class BusinessLicense extends BaseDomain{ + + private static final long serialVersionUID = 7154170738721391613L; + + private String enterpriseId = null; //店铺序列号 + + private String name = null; //营业执照名称 + + private String image = null; //营业执照图片 + + private String businessScope = null; //经营范围 + + private String validityType = null; //经营时间类型 + + private String validity = null; //经营时间 + + private String legalRepresentative = null; //法定代表人 + + private String registrationNumber = null; //营业执照注册号 + + private String address = null; //地址 + + private User creater = null; // 创建者 + + private Timestamp createTime = null; // 创建时间 + + private User updater = null; // 更新者 + + private Timestamp updateTime = null; // 更新时间 + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getBusinessScope() { + return businessScope; + } + + public void setBusinessScope(String businessScope) { + this.businessScope = businessScope; + } + + public String getValidityType() { + return validityType; + } + + public void setValidityType(String validityType) { + this.validityType = validityType; + } + + public String getValidity() { + return validity; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public String getLegalRepresentative() { + return legalRepresentative; + } + + public void setLegalRepresentative(String legalRepresentative) { + this.legalRepresentative = legalRepresentative; + } + + public String getRegistrationNumber() { + return registrationNumber; + } + + public void setRegistrationNumber(String registrationNumber) { + this.registrationNumber = registrationNumber; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public User getCreater() { + return creater; + } + + public void setCreater(User creater) { + this.creater = creater; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public User getUpdater() { + return updater; + } + + public void setUpdater(User updater) { + this.updater = updater; + } + + public Timestamp getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + } + + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/domain/BusinessLicense.mbm.xml b/src/main/java/com/dreawer/shopcenter/domain/BusinessLicense.mbm.xml new file mode 100644 index 0000000..31237a9 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/BusinessLicense.mbm.xml @@ -0,0 +1,78 @@ + + + + + + + + + + INSERT INTO aci_ent_lic(id, ent_id, name, image, bus_sco, leg_reps, val_typ, validity, address, + bus_reg_num, crer_id) + VALUES(#{id}, #{enterpriseId}, #{name}, #{image}, #{businessScope}, #{legalRepresentative}, + #{validityType}, #{validity}, #{address}, #{registrationNumber}, #{creater.id}) + + + + + + + + + + + + UPDATE aci_ent_lic + SET ent_id=#{enterpriseId},name=#{name},image=#{image},bus_sco=#{businessScope}, + leg_reps=#{legalRepresentative},val_typ=#{validityType},validity=#{validity},address=#{address}, + bus_reg_num=#{registrationNumber},updr_id = #{updater.id}, upd_tim = #{updateTime} + WHERE id = #{id} + + + + + + + + + + + + + + + + + + + SELECT id, ent_id, name, image, bus_sco, leg_reps, val_typ, validity, address, bus_reg_num, + crer_id,cre_tim + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/dreawer/shopcenter/domain/Certificate.java b/src/main/java/com/dreawer/shopcenter/domain/Certificate.java new file mode 100644 index 0000000..2e03ada --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/Certificate.java @@ -0,0 +1,128 @@ +package com.dreawer.shopcenter.domain; + +import com.dreawer.dream.domain.BaseDomain; +import com.dreawer.user.domain.User; + +import java.sql.Timestamp; + +/** + * Certificate 其他证件实体类。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class Certificate extends BaseDomain{ + + private static final long serialVersionUID = -2105923816019595718L; + + private String enterpriseId = null; //店铺id + + private String name = null; //许可证类型名称 + + private String image = null; //营业执照图片 + + private String number = null; //营业执照编号 + + private String validityType = null; //类型(LONG_TERM-长期、REGULARLY-定期) + + private String validity = null; //有效期 + + private String address = null; //地址 + + private User creater = null; // 创建者 + + private Timestamp createTime = null; // 创建时间 + + private User updater = null; // 更新者 + + private Timestamp updateTime = null; // 更新时间 + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public String getValidityType() { + return validityType; + } + + public void setValidityType(String validityType) { + this.validityType = validityType; + } + + public String getValidity() { + return validity; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public User getCreater() { + return creater; + } + + public void setCreater(User creater) { + this.creater = creater; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public User getUpdater() { + return updater; + } + + public void setUpdater(User updater) { + this.updater = updater; + } + + public Timestamp getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + } + + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/domain/Certificate.mbm.xml b/src/main/java/com/dreawer/shopcenter/domain/Certificate.mbm.xml new file mode 100644 index 0000000..0d9e65b --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/Certificate.mbm.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + INSERT INTO aci_ent_cert(id, ent_id, name, image, number, address,val_typ,validity, + crer_id) + VALUES(#{id}, #{enterpriseId}, #{name}, #{image}, #{number}, #{address}, #{validityType}, + #{validity}, #{creater.id}) + + + + + + + + + + + + + UPDATE aci_ent_cert + + + image=#{image}, + + + number=#{number}, + + + name=#{name}, + + + address=#{address}, + + + val_typ=#{validityType}, + + + validity=#{validity}, + + + updr_id = #{updater.id}, + + + upd_tim = #{updateTime}, + + + WHERE id = #{id} + + + + + + + + + + + + + + + + + + + SELECT id, ent_id, name, image, number, address, val_typ, validity, + crer_id, cre_tim + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/dreawer/shopcenter/domain/Enterprise.java b/src/main/java/com/dreawer/shopcenter/domain/Enterprise.java new file mode 100644 index 0000000..064855d --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/Enterprise.java @@ -0,0 +1,300 @@ +package com.dreawer.shopcenter.domain; + +import com.dreawer.dream.domain.BaseDomain; +import com.dreawer.user.domain.User; + +import java.sql.Timestamp; + +public class Enterprise extends BaseDomain{ + + private static final long serialVersionUID = 8940480431090127598L; + + private String appid = null; + + private String category = null; + + private String name = null; + + private String shortname = null; + + private String logo = null; + + private String intro = null; + + private String coordinate = null; // 位置坐标 + + private String province = null; + + private String city = null; + + private String area = null; + + private String detail = null; + + private String email = null; + + private String phone = null; + + private String mobile = null; + + private String bootImage = null; + + private Integer bootTime = null; + + private String posters = null; + + private String telephone = null; + + private String merchanCategories = null; + + private Boolean memberRegisterPort = true; //是否在商品详情显示会员注册通道 + + private String growthRules = null; //会员成长值规则JSON + + private String url = null; + + public String getMerchanCategories() { + return merchanCategories; + } + + public void setMerchanCategories(String merchanCategories) { + this.merchanCategories = merchanCategories; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getGrowthRules() { + return growthRules; + } + + public void setGrowthRules(String growthRules) { + this.growthRules = growthRules; + } + + public Boolean getMemberRegisterPort() { + return memberRegisterPort; + } + + public void setMemberRegisterPort(Boolean memberRegisterPort) { + this.memberRegisterPort = memberRegisterPort; + } + + private User creater = null; // 创建者 + + private Timestamp createTime = null; // 创建时间 + + private User updater = null; // 更新者 + + private Timestamp updateTime = null; // 更新时间 + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getShortname() { + return shortname; + } + + public void setShortname(String shortname) { + this.shortname = shortname; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getArea() { + return area; + } + + public void setArea(String area) { + this.area = area; + } + + public String getDetail() { + return detail; + } + + public void setDetail(String detail) { + this.detail = detail; + } + + public User getCreater() { + return creater; + } + + public void setCreater(User creater) { + this.creater = creater; + } + + public Timestamp getCreateTime() { + return createTime; + } + + public void setCreateTime(Timestamp createTime) { + this.createTime = createTime; + } + + public User getUpdater() { + return updater; + } + + public void setUpdater(User updater) { + this.updater = updater; + } + + public Timestamp getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Timestamp updateTime) { + this.updateTime = updateTime; + } + + public String getIntro() { + return intro; + } + + public void setIntro(String intro) { + this.intro = intro; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPosters() { + return posters; + } + + public void setPosters(String posters) { + this.posters = posters; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getAppid() { + return appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + public String getCoordinate() { + return coordinate; + } + + public void setCoordinate(String coordinate) { + this.coordinate = coordinate; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getBootImage() { + return bootImage; + } + + public void setBootImage(String bootImage) { + this.bootImage = bootImage; + } + + public Integer getBootTime() { + return bootTime; + } + + public void setBootTime(Integer bootTime) { + this.bootTime = bootTime; + } + + @Override + public String toString() { + return "Enterprise{" + + "appid='" + appid + '\'' + + ", category='" + category + '\'' + + ", name='" + name + '\'' + + ", shortname='" + shortname + '\'' + + ", logo='" + logo + '\'' + + ", intro='" + intro + '\'' + + ", coordinate='" + coordinate + '\'' + + ", province='" + province + '\'' + + ", city='" + city + '\'' + + ", area='" + area + '\'' + + ", detail='" + detail + '\'' + + ", email='" + email + '\'' + + ", phone='" + phone + '\'' + + ", mobile='" + mobile + '\'' + + ", bootImage='" + bootImage + '\'' + + ", bootTime=" + bootTime + + ", posters='" + posters + '\'' + + ", telephone='" + telephone + '\'' + + ", url='" + url + '\'' + + ", creater=" + creater + + ", createTime=" + createTime + + ", updater=" + updater + + ", updateTime=" + updateTime + + '}'; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/domain/Enterprise.mbm.xml b/src/main/java/com/dreawer/shopcenter/domain/Enterprise.mbm.xml new file mode 100644 index 0000000..bcefd9a --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/domain/Enterprise.mbm.xml @@ -0,0 +1,133 @@ + + + + + + + + + + + + INSERT INTO aci_enterprise(id, app_id, app_ctg, name, sht_nam, logo, intro, province, city, + area, detail, email, phone,url,crer_id) + VALUES(#{id}, #{appid}, #{category}, #{name}, #{shortname}, #{logo}, #{intro}, #{province}, + #{city}, #{area}, #{detail}, #{email}, #{phone},#{url},#{creater.id}) + + + + + + + + + DELETE FROM aci_enterprise + WHERE id = #{id} + + + + + + + + + UPDATE aci_enterprise + SET name=#{name}, sht_nam=#{shortname}, logo=#{logo},intro=#{intro}, coordinate=#{coordinate}, + province=#{province}, city=#{city}, area=#{area}, detail=#{detail}, email=#{email}, phone=#{phone}, + mobile=#{mobile}, bot_img=#{bootImage}, bot_tim=#{bootTime}, posters=#{posters}, telephone=#{telephone}, + url=#{url},updr_id=#{updater.id}, upd_tim=#{updateTime} + WHERE id = #{id} + + + + UPDATE aci_enterprise + SET mer_cate=#{merchanCategories} + WHERE id=#{id} + + + + UPDATE aci_enterprise + SET mem_por=#{type} + WHERE id=#{id} + + + + + + + + + + + + + + + + + + + + + + + id, app_id, app_ctg, name, sht_nam, logo ,intro, coordinate, province, city, area, detail, email, + phone, mobile, bot_img, bot_tim, posters, telephone,mer_cate,mem_por,gro_rule,url,cre_tim + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/dreawer/shopcenter/form/AddAddressForm.java b/src/main/java/com/dreawer/shopcenter/form/AddAddressForm.java new file mode 100644 index 0000000..7f371b9 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/AddAddressForm.java @@ -0,0 +1,88 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import javax.validation.constraints.Pattern; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * AddAddressForm + * 添加地址表单 + * @author fenrir + * @Date 17-12-25 + */ +public class AddAddressForm { + + @NotEmpty(message = VAL_CONSIGNEE_NOTEMPTY) + @Length(min = 0,max=20, message=VAL_CONSIGNEE_LENTH) + private String consignee = null; + + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message = VAL_CONTACT_METHOD) + @Pattern(regexp="^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$", + message=VAL_PHONE_WRONG) + private String contact = null; + + @NotEmpty(message = VAL_SHIPPING_ADDRESS_NOTEMPTY) + private String shippingAddress = null; + + @NotEmpty(message = VAL_DETAIL_ADDRESS_NOTEMPTY) + @Length(min =0,max = 500,message = VAL_ADDRESS_LENGTH) + private String address = null; + + @NotEmpty(message = VAL_POSTCODE_NOTEMPTY) + @Pattern(regexp = "[0-9][0-9][0-9][0-9][0-9][0-9]",message = VAL_POSTCODE_WRONG) + private String postcode = null; + + public String getConsignee() { + return consignee; + } + + public void setConsignee(String consignee) { + this.consignee = consignee; + } + + public String getContact() { + return contact; + } + + public void setContact(String contact) { + this.contact = contact; + } + + public String getShippingAddress() { + return shippingAddress; + } + + public void setShippingAddress(String shippingAddress) { + this.shippingAddress = shippingAddress; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + + public String getPostcode() { + return postcode; + } + + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/AddBusinessLicenseForm.java b/src/main/java/com/dreawer/shopcenter/form/AddBusinessLicenseForm.java new file mode 100644 index 0000000..cf00149 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/AddBusinessLicenseForm.java @@ -0,0 +1,20 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_ENTERPRISE_ID_EMPTY; + +public class AddBusinessLicenseForm extends BaseBusinessLicenseForm { + + @NotEmpty(message = VAL_ENTERPRISE_ID_EMPTY) + private String enterpriseId = null; //店铺序列号 + + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } + +} diff --git a/src/main/java/com/dreawer/shopcenter/form/AddCategoryForm.java b/src/main/java/com/dreawer/shopcenter/form/AddCategoryForm.java new file mode 100644 index 0000000..01c082e --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/AddCategoryForm.java @@ -0,0 +1,35 @@ +package com.dreawer.shopcenter.form; + +import javax.validation.constraints.NotNull; + +/** + * AddCategoryForm + * + * @author fenrir + * @Date 18-3-30 + */ +public class AddCategoryForm { + + @NotNull(message = "类目列表不能为空") + private String ids; //类目列表 + + @NotNull(message = "店铺ID不能为空") + private String storeId; //店铺ID + + + public String getIds() { + return ids; + } + + public void setIds(String ids) { + this.ids = ids; + } + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/AddCertificateForm.java b/src/main/java/com/dreawer/shopcenter/form/AddCertificateForm.java new file mode 100644 index 0000000..4ca7dbb --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/AddCertificateForm.java @@ -0,0 +1,19 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_ENTERPRISE_ID_EMPTY; + +public class AddCertificateForm extends BaseCertificateForm{ + + @NotEmpty(message=VAL_ENTERPRISE_ID_EMPTY) + private String enterpriseId = null; //店铺id + + public String getEnterpriseId() { + return enterpriseId; + } + + public void setEnterpriseId(String enterpriseId) { + this.enterpriseId = enterpriseId; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/AddEnterpriseForm.java b/src/main/java/com/dreawer/shopcenter/form/AddEnterpriseForm.java new file mode 100644 index 0000000..a76c665 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/AddEnterpriseForm.java @@ -0,0 +1,20 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_APP_ID_EMPTY; + +public class AddEnterpriseForm extends BaseEnterpriseForm{ + + @NotEmpty(message=VAL_APP_ID_EMPTY) + private String appid = null; + + public String getAppid() { + return appid; + } + + public void setAppid(String appid) { + this.appid = appid; + } + +} diff --git a/src/main/java/com/dreawer/shopcenter/form/BaseBusinessLicenseForm.java b/src/main/java/com/dreawer/shopcenter/form/BaseBusinessLicenseForm.java new file mode 100644 index 0000000..faff103 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/BaseBusinessLicenseForm.java @@ -0,0 +1,106 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import javax.validation.constraints.Pattern; + +import static com.dreawer.retail.MessageConstants.*; + +public class BaseBusinessLicenseForm { + + @NotEmpty(message=VAL_NAME_NOTEMPTY) + @Length(min=1, max=50, message=VAL_NAME_LENTH) + private String name = null; //营业执照名称 + + @NotEmpty(message=VAL_IMAGE_NOTEMPTY) + @Length(min=1, max=255, message=VAL_IMAGE_LENTH) + private String image = null; //营业执照图片 + + @Length(min=0, max=1000, message=VAL_SCOPE_LENTH) + private String businessScope = null; //经营范围 + + private String validityType = null; //经营时间类型 + + @Length(min=1, max=50, message=VAL_VAL_LENTH) + private String validity = null; //经营时间 + + @NotEmpty(message=VAL_LEGAL_NOTEMPTY) + @Length(min=1, max=50, message=VAL_LEGAL_LENTH) + private String legalRepresentative = null; //法定代表人 + + @NotEmpty(message=VAL_NUM_NOTEMPTY) + @Pattern(regexp="^[0-9a-zA-Z]+$", message=VAL_NUM_TYPE_WRONG) + @Length(min=1, max=60, message=VAL_NUM_LENTH) + private String registrationNumber = null; //营业执照注册号 + + @NotEmpty(message=VAL_ADDRESS_NOTEMPTY) + @Length(min=1, max=500, message=VAL_ADDRESS_LENTH) + private String address = null; //地址 + + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getBusinessScope() { + return businessScope; + } + + public void setBusinessScope(String businessScope) { + this.businessScope = businessScope; + } + + public String getValidityType() { + return validityType; + } + + public void setValidityType(String validityType) { + this.validityType = validityType; + } + + public String getValidity() { + return validity; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public String getLegalRepresentative() { + return legalRepresentative; + } + + public void setLegalRepresentative(String legalRepresentative) { + this.legalRepresentative = legalRepresentative; + } + + public String getRegistrationNumber() { + return registrationNumber; + } + + public void setRegistrationNumber(String registrationNumber) { + this.registrationNumber = registrationNumber; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } + +} diff --git a/src/main/java/com/dreawer/shopcenter/form/BaseCertificateForm.java b/src/main/java/com/dreawer/shopcenter/form/BaseCertificateForm.java new file mode 100644 index 0000000..794019d --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/BaseCertificateForm.java @@ -0,0 +1,76 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; + +import javax.validation.constraints.Pattern; + +import static com.dreawer.retail.MessageConstants.*; + +public class BaseCertificateForm { + + @Length(min=1, max=50, message=VAL_NAME_LENTH) + private String name = null; //许可证类型名称 + + @Length(min=1, max=255, message=VAL_IMAGE_LENTH) + private String image = null; //营业执照图片 + + @Pattern(regexp="^[0-9a-zA-Z]+$", message=VAL_NUM_TYPE_WRONG) + @Length(min=1, max=60, message=VAL_NUM_LENTH) + private String number = null; //营业执照编号 + + private String validityType = null; //类型(LONG_TERM-长期、REGULARLY-定期) + + @Length(min=1, max=50, message=VAL_VAL_LENTH) + private String validity = null; //有效期 + + @Length(min=1, max=500, message=VAL_ADDRESS_LENTH) + private String address = null; //地址 + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } + + public String getValidityType() { + return validityType; + } + + public void setValidityType(String validityType) { + this.validityType = validityType; + } + + public String getValidity() { + return validity; + } + + public void setValidity(String validity) { + this.validity = validity; + } + + public String getAddress() { + return address; + } + + public void setAddress(String address) { + this.address = address; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/BaseEnterpriseForm.java b/src/main/java/com/dreawer/shopcenter/form/BaseEnterpriseForm.java new file mode 100644 index 0000000..336c9ef --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/BaseEnterpriseForm.java @@ -0,0 +1,146 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.Email; + +import javax.validation.constraints.Pattern; + +import static com.dreawer.retail.MessageConstants.*; + + +public class BaseEnterpriseForm { + + @Length(min=1, max=50, message=VAL_NAME_LENTH) + private String name = null; + + @Length(min=1, max=30, message=VAL_SHORTNAME_LENTH) + private String shortname = null; + + @Length(min=1, max=200, message=VAL_LOGO_LENTH) + private String logo = null; + + @Length(min=1, max=400, message=VAL_INTRO_LENTH) + private String intro = null; + + private String coordinate = null; // 位置坐标 + + @Length(min=1, max=500, message=VAL_ADDRESS_LENTH) + private String detail = null; + + @Email(message=VAL_EMAIL_WRONG) + private String email = null; + + //@Pattern(regexp="^((0\\d{2,3}-\\d{7,8})|(1[3584]\\d{9}))$", + // message=VAL_PHONE_WRONG) + private String phone = null; + + @Pattern(regexp="^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$", + message=VAL_PHONE_WRONG) + private String mobile = null; + + @Length(min=1, max=1200, message=VAL_POSTERS_LENTH) + private String posters = null; + + @Pattern(regexp="^1(3[0-9]|4[57]|5[0-35-9]|7[0135678]|8[0-9])\\d{8}$", + message=VAL_PHONE_WRONG) + private String telephone = null; + + @Length(min = 1,max = 200,message = VAL_OFFICIAL_SITE_LENGTH) + private String url = null; //官方网站 + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getShortname() { + return shortname; + } + + public void setShortname(String shortname) { + this.shortname = shortname; + } + + public String getLogo() { + return logo; + } + + public void setLogo(String logo) { + this.logo = logo; + } + + public String getDetail() { + return detail; + } + + public void setDetail(String detail) { + this.detail = detail; + } + + public String getIntro() { + return intro; + } + + public void setIntro(String intro) { + this.intro = intro; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPosters() { + return posters; + } + + public void setPosters(String posters) { + this.posters = posters; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getCoordinate() { + return coordinate; + } + + public void setCoordinate(String coordinate) { + this.coordinate = coordinate; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/CertificateQueryForm.java b/src/main/java/com/dreawer/shopcenter/form/CertificateQueryForm.java new file mode 100644 index 0000000..8c9c22b --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/CertificateQueryForm.java @@ -0,0 +1,41 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_CERT_TYPE_NOTEMPTY; +import static com.dreawer.retail.MessageConstants.VAL_STORE_ID_NOTEMPTY; + +/** + * Created by fenrir on 9/26/17. + */ + +/** + * CertificateQueryForm 查询其他证件表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class CertificateQueryForm { + + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_CERT_TYPE_NOTEMPTY) + private String type = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditAddressForm.java b/src/main/java/com/dreawer/shopcenter/form/EditAddressForm.java new file mode 100644 index 0000000..3be75b4 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditAddressForm.java @@ -0,0 +1,25 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_ADDRESS_ID_NOTEMPTY; + +/** + * EditAddressForm + * 修改地址表单 + * @author fenrir + * @Date 17-12-25 + */ +public class EditAddressForm extends AddAddressForm{ + + @NotEmpty(message = VAL_ADDRESS_ID_NOTEMPTY) + private String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditBusinessLicenseForm.java b/src/main/java/com/dreawer/shopcenter/form/EditBusinessLicenseForm.java new file mode 100644 index 0000000..feb1f1e --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditBusinessLicenseForm.java @@ -0,0 +1,21 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_OBJECT_ID_NOT_EMPTY; + +public class EditBusinessLicenseForm extends BaseBusinessLicenseForm { + + + @NotEmpty(message = VAL_OBJECT_ID_NOT_EMPTY) + private String id = null; //店铺序列号 + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditBusinessTypeForm.java b/src/main/java/com/dreawer/shopcenter/form/EditBusinessTypeForm.java new file mode 100644 index 0000000..2aa5ab7 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditBusinessTypeForm.java @@ -0,0 +1,38 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditBusinessTypeForm 编辑经营类型表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditBusinessTypeForm { + + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_BUS_TYP_NOTEMPTY) + @Length(min=1, max=50, message=VAL_BUS_TYP_LENGTH) + private String businessType = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getBusinessType() { + return businessType; + } + + public void setBusinessType(String businessType) { + this.businessType = businessType; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditCertificateForm.java b/src/main/java/com/dreawer/shopcenter/form/EditCertificateForm.java new file mode 100644 index 0000000..a34208a --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditCertificateForm.java @@ -0,0 +1,21 @@ +package com.dreawer.shopcenter.form; + + +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_OBJECT_ID_NOT_EMPTY; + +public class EditCertificateForm extends BaseCertificateForm{ + + @NotEmpty(message=VAL_OBJECT_ID_NOT_EMPTY) + private String id = null; //店铺id + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditDeliveryTimeForm.java b/src/main/java/com/dreawer/shopcenter/form/EditDeliveryTimeForm.java new file mode 100644 index 0000000..e349f65 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditDeliveryTimeForm.java @@ -0,0 +1,37 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditDeliveryTimeForm 编辑送货时间表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditDeliveryTimeForm { + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_DEVR_TIME_NOTEMPTY) + @Length(min=1, max=10, message=VAL_DEVR_TIME_LENGTH) + private String deliveryTime = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getDeliveryTime() { + return deliveryTime; + } + + public void setDeliveryTime(String deliveryTime) { + this.deliveryTime = deliveryTime; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditEnterpriseForm.java b/src/main/java/com/dreawer/shopcenter/form/EditEnterpriseForm.java new file mode 100644 index 0000000..7dcdab3 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditEnterpriseForm.java @@ -0,0 +1,53 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.VAL_BOOT_IMG_LENTH; +import static com.dreawer.retail.MessageConstants.VAL_OBJECT_ID_NOT_EMPTY; + +public class EditEnterpriseForm extends BaseEnterpriseForm{ + + @NotEmpty(message=VAL_OBJECT_ID_NOT_EMPTY) + private String id = null; + + private String value = null; + + @Length(min=2, max=200, message=VAL_BOOT_IMG_LENTH) + private String bootImage = null; + + private Integer bootTime = null; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getBootImage() { + return bootImage; + } + + public void setBootImage(String bootImage) { + this.bootImage = bootImage; + } + + public Integer getBootTime() { + return bootTime; + } + + public void setBootTime(Integer bootTime) { + this.bootTime = bootTime; + } + +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditFrontPicForm.java b/src/main/java/com/dreawer/shopcenter/form/EditFrontPicForm.java new file mode 100644 index 0000000..80fb254 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditFrontPicForm.java @@ -0,0 +1,38 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditFrontPicForm 编辑门脸照片表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditFrontPicForm { + + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_FNT_PIC_NOTEMPTY) + @Length(min=1, max=255, message=VAL_FNT_PIC_LENGTH) + private String frontPic = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getFrontPic() { + return frontPic; + } + + public void setFrontPic(String frontPic) { + this.frontPic = frontPic; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditInteriorPicForm.java b/src/main/java/com/dreawer/shopcenter/form/EditInteriorPicForm.java new file mode 100644 index 0000000..efd3eae --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditInteriorPicForm.java @@ -0,0 +1,37 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditInteriorPicForm 编辑店内照片表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditInteriorPicForm { + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_INI_PIC_NOTEMPTY) + @Length(min=1, max=1275, message=VAL_INI_PIC_LENGTH) + private String interiorPic = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getInteriorPic() { + return interiorPic; + } + + public void setInteriorPic(String interiorPic) { + this.interiorPic = interiorPic; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditIntroForm.java b/src/main/java/com/dreawer/shopcenter/form/EditIntroForm.java new file mode 100644 index 0000000..ed7b3b8 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditIntroForm.java @@ -0,0 +1,37 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditIntroForm 编辑店铺简介表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditIntroForm { + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_INTRO_NOTEMPTY) + @Length(min=1, max=2000, message=VAL_INTRO_LENGTH) + private String intro = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getIntro() { + return intro; + } + + public void setIntro(String intro) { + this.intro = intro; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditMerchanCategoriesForm.java b/src/main/java/com/dreawer/shopcenter/form/EditMerchanCategoriesForm.java new file mode 100644 index 0000000..a61bd56 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditMerchanCategoriesForm.java @@ -0,0 +1,34 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +/** + * EditMerchanCategoriesForm + * + * @author fenrir + * @Date 18-4-17 + */ +public class EditMerchanCategoriesForm { + + @NotEmpty(message = "店铺ID不能为空") + private String storeId = null; + + @NotEmpty(message = "开启状态不能为空") + private String type = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditPhoneForm.java b/src/main/java/com/dreawer/shopcenter/form/EditPhoneForm.java new file mode 100644 index 0000000..06fe918 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditPhoneForm.java @@ -0,0 +1,39 @@ +package com.dreawer.shopcenter.form; + +import org.hibernate.validator.constraints.NotEmpty; + +import javax.validation.constraints.Pattern; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditPhoneForm 编辑店铺电话表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditPhoneForm { + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_PHONE_NOTEMPTY) + @Pattern(regexp = "(^\\d{3}-\\d{8}$|^\\d{4}-\\d{7,8})$|^(\\d{8})$|(^\\d{3}\\d{8}|\\d{4}\\d{7,8}$)", + message=VAL_PHONE_LENGTH) + private String phone = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditPostersForm.java b/src/main/java/com/dreawer/shopcenter/form/EditPostersForm.java new file mode 100644 index 0000000..7fc26dd --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditPostersForm.java @@ -0,0 +1,37 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditPostersForm 编辑店铺海报列表表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditPostersForm { + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_POSTERS_NOTEMPTY) + @Length(min=1, max=1300, message=VAL_POSTERS_LENGTH) + private String posters = null; + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } + + public String getPosters() { + return posters; + } + + public void setPosters(String posters) { + this.posters = posters; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/EditStoreNameForm.java b/src/main/java/com/dreawer/shopcenter/form/EditStoreNameForm.java new file mode 100644 index 0000000..e7a8855 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/EditStoreNameForm.java @@ -0,0 +1,38 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.dream.validation.constraint.Length; +import org.hibernate.validator.constraints.NotEmpty; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * EditStoreNameForm 编辑店铺名称表单。 + * @author lyan + * @since Dreawer 2.0 + * @version 1.0 + */ +public class EditStoreNameForm { + + @NotEmpty(message=VAL_STORE_ID_NOTEMPTY) + private String storeId = null; + + @NotEmpty(message=VAL_STORE_NAME_NOTEMPTY) + @Length(min=1, max=50, message=VAL_STORE_NAME_LENGTH) + private String name = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getStoreId() { + return storeId; + } + + public void setStoreId(String storeId) { + this.storeId = storeId; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/ViewCountCouponPair.java b/src/main/java/com/dreawer/shopcenter/form/ViewCountCouponPair.java new file mode 100644 index 0000000..10f639f --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/ViewCountCouponPair.java @@ -0,0 +1,34 @@ +package com.dreawer.shopcenter.form; + +import com.dreawer.coupon.domain.UserUnusedCoupon; + +import java.math.BigDecimal; + +/** + * ViewCountCouponPair + * 减扣金额和优惠劵键值对 + * @author fenrir + * @Date 18-1-27 + */ +public class ViewCountCouponPair { + + private BigDecimal count = null; + + private UserUnusedCoupon coupon; + + public BigDecimal getCount() { + return count; + } + + public void setCount(BigDecimal count) { + this.count = count; + } + + public UserUnusedCoupon getCoupon() { + return coupon; + } + + public void setCoupon(UserUnusedCoupon coupon) { + this.coupon = coupon; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/form/ViewCouponByOrderForm.java b/src/main/java/com/dreawer/shopcenter/form/ViewCouponByOrderForm.java new file mode 100644 index 0000000..4837507 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/ViewCouponByOrderForm.java @@ -0,0 +1,68 @@ +package com.dreawer.shopcenter.form; + +import javax.validation.constraints.NotNull; + +import static com.dreawer.coupon.MessageConstants.*; + +/** + * ViewCouponByOrderForm + * 查询订单可用优惠劵列表 + * @author fenrir + * @Date 18-1-25 + */ +public class ViewCouponByOrderForm { + + @NotNull(message = VAL_MERCHANDISE_ID_NOTEMPTY) + String merchandiseId = null; //商品ID + + @NotNull(message = VAL_SKU_ID_NOTEMPTY) + String skuId = null; //skuID + + @NotNull(message = VAL_QUANTITY_NOTEMPTY) + String quantity = null; //数量 + + String isPacking = null; //是否包装 + + String promotionId = null; //活动ID + + public String getPromotionId() { + return promotionId; + } + + public void setPromotionId(String promotionId) { + this.promotionId = promotionId; + } + + public String getMerchandiseId() { + return merchandiseId; + } + + public void setMerchandiseId(String merchandiseId) { + this.merchandiseId = merchandiseId; + } + + public String getSkuId() { + return skuId; + } + + public void setSkuId(String skuId) { + this.skuId = skuId; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getIsPacking() { + return isPacking; + } + + public void setIsPacking(String isPacking) { + this.isPacking = isPacking; + } +} + diff --git a/src/main/java/com/dreawer/shopcenter/form/ViewReductionForm.java b/src/main/java/com/dreawer/shopcenter/form/ViewReductionForm.java new file mode 100644 index 0000000..db96c68 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/form/ViewReductionForm.java @@ -0,0 +1,57 @@ +package com.dreawer.shopcenter.form; + +import javax.validation.constraints.NotNull; + +import static com.dreawer.retail.MessageConstants.*; + +/** + * ViewReductionForm + * + * @author fenrir + * @Date 18-1-25 + */ +public class ViewReductionForm { + + @NotNull(message = VAL_SKU_ID_NOTEMPTY) + String skuId = null; //商品skuID + + @NotNull(message = VAL_QUANTITY_NOTEMPTY) + String quantity = null; //数量 + + @NotNull(message = VAL_IS_PACKING_NOTEMPTY) + String isPacking = null; //是否包 + + String promotionId = null; //活动ID + + public String getPromotionId() { + return promotionId; + } + + public void setPromotionId(String promotionId) { + this.promotionId = promotionId; + } + + public String getSkuId() { + return skuId; + } + + public void setSkuId(String skuId) { + this.skuId = skuId; + } + + public String getQuantity() { + return quantity; + } + + public void setQuantity(String quantity) { + this.quantity = quantity; + } + + public String getIsPacking() { + return isPacking; + } + + public void setIsPacking(String isPacking) { + this.isPacking = isPacking; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/lang/OperatingStatus.java b/src/main/java/com/dreawer/shopcenter/lang/OperatingStatus.java new file mode 100644 index 0000000..73d7d14 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/lang/OperatingStatus.java @@ -0,0 +1,26 @@ +package com.dreawer.shopcenter.lang; + +public enum OperatingStatus { + + /** 营业 */ + OPEN, + + /** 非营业 */ + CLOSED; + + /** + * 获取营业状态。 + * @param name 状态名称。 + * @return 枚举对象。 + * @author kael + * @since 1.0 + */ + public static OperatingStatus get(String name) { + for (OperatingStatus status : OperatingStatus.values()) { + if (status.toString().equalsIgnoreCase(name)) { + return status; + } + } + return null; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/lang/StringArrayTypeHandler.java b/src/main/java/com/dreawer/shopcenter/lang/StringArrayTypeHandler.java new file mode 100644 index 0000000..7483fbe --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/lang/StringArrayTypeHandler.java @@ -0,0 +1,55 @@ +package com.dreawer.shopcenter.lang; + +import org.apache.ibatis.type.BaseTypeHandler; +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedJdbcTypes; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +/** + * StringArrayTypeHandler + * + * @author fenrir + * @Date 17-10-18 + */ +@MappedJdbcTypes({JdbcType.VARCHAR}) +public class StringArrayTypeHandler extends BaseTypeHandler { + + @Override + public String[] getNullableResult(ResultSet rs, String columnName) + throws SQLException { + return getStringArray(rs.getString(columnName)); + } + + @Override + public String[] getNullableResult(ResultSet rs, int columnIndex) + throws SQLException { + return this.getStringArray(rs.getString(columnIndex)); + } + + @Override + public String[] getNullableResult(CallableStatement cs, int columnIndex) + throws SQLException { + return this.getStringArray(cs.getString(columnIndex)); + } + + @Override + public void setNonNullParameter(PreparedStatement ps, int i, + String[] parameter, JdbcType jdbcType) throws SQLException { + //由于BaseTypeHandler中已经把parameter为null的情况做了处理,所以这里我们就不用再判断parameter是否为空了,直接用就可以了 + StringBuffer result = new StringBuffer(); + for (String value : parameter) + result.append(value).append(","); + result.deleteCharAt(result.length()-1); + ps.setString(i, result.toString()); + } + + private String[] getStringArray(String columnValue) { + if (columnValue == null) + return null; + return columnValue.split(","); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/persistence/AddressDao.java b/src/main/java/com/dreawer/shopcenter/persistence/AddressDao.java new file mode 100644 index 0000000..ae4caed --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/persistence/AddressDao.java @@ -0,0 +1,54 @@ +package com.dreawer.shopcenter.persistence; + +import com.dreawer.dream.persistence.mybatis.MyBatisBaseDao; +import com.dreawer.retail.domain.Address; +import org.springframework.stereotype.Repository; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.dreawer.retail.DAOConstants.ADDRESS_DAO; +import static com.dreawer.retail.DomainConstants.ID; + +/** + * AddressDao + * 地址Dao + * @author fenrir + * @Date 17-12-25 + */ + +@Repository(ADDRESS_DAO) +public class AddressDao extends MyBatisBaseDao{ + + + public Integer getCountByStoreId(String storeId) { + return selectOne("getCountByStoreId",storeId); + } + + public void addAddress(Address address) { + insert("save",address); + } + + public Address findAddressById(String id) { + Map param = new HashMap<>(); + param.put(ID,id); + return selectOne("findAddressById",param); + } + + public void updateAddress(Address address) { + update("updateAddress",address); + } + + public void removeAddress(Address address) { + delete("deleteAddress",address); + } + + public void updateDefaultAddress(Address address) { + update("updateDefaultAddress",address); + } + + public List
findAllAddressByStoreId(String storeId) { + return selectList("findAllAddressByStoreId",storeId); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/persistence/BusinessLicenseDao.java b/src/main/java/com/dreawer/shopcenter/persistence/BusinessLicenseDao.java new file mode 100644 index 0000000..371727b --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/persistence/BusinessLicenseDao.java @@ -0,0 +1,45 @@ +package com.dreawer.shopcenter.persistence; + +import com.dreawer.dream.persistence.mybatis.MyBatisBaseDao; +import com.dreawer.retail.domain.BusinessLicense; +import org.springframework.stereotype.Repository; + +import static com.dreawer.retail.DAOConstants.BUSINESS_LICENSE_DAO; + +@Repository(BUSINESS_LICENSE_DAO) +public class BusinessLicenseDao extends MyBatisBaseDao{ + + /** + * 根据ID获取营业执照信息。 + * @param storeId 营业时间ID。 + * @return 营业执照信息。 + */ + public BusinessLicense findBusinessLicense(String storeId) { + return selectOne("findBusinessLicense",storeId); + } + + /** + * 修改营业执照信息。 + * @param businessLicense 营业时间ID。 + */ + public void updateBusinessLicense(BusinessLicense businessLicense) { + update("updateBusinessLicense",businessLicense); + } + + /** + * 添加营业执照。 + * @param businessLicense 营业执照信息。 + */ + public void addBusinessLicense(BusinessLicense businessLicense) { + insert("addBusinessLicense", businessLicense); + } + + /** + * 通过id查询营业执照。 + * @param id 执照id。 + * @return + */ + public BusinessLicense findBusinessLicenseById(String id) { + return selectOne("findBusinessLicenseById", id); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/persistence/CertificateDao.java b/src/main/java/com/dreawer/shopcenter/persistence/CertificateDao.java new file mode 100644 index 0000000..9d7ad62 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/persistence/CertificateDao.java @@ -0,0 +1,39 @@ +package com.dreawer.shopcenter.persistence; + +import com.dreawer.dream.persistence.mybatis.MyBatisBaseDao; +import com.dreawer.retail.domain.Certificate; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import static com.dreawer.retail.DAOConstants.CERTIFICATE_DAO; + +@Repository(CERTIFICATE_DAO) +public class CertificateDao extends MyBatisBaseDao{ + + /** + * 查找其他证件信息。 + * @param storeId 店铺id + * @param type 证件类型 + * @return 证件信息 + */ + public Certificate findCertificateById(String id) { + return selectOne("findCertificateById", id); + } + + /** + * 编辑其他证件信息。 + * @param certificate 证件信息。 + */ + public void updateCertificate(Certificate certificate) { + update("updateCertificate",certificate); + } + + public void addCertificate(Certificate certificate) { + insert("addCertificate", certificate); + } + + public List findCertificates(String enterpriseId) { + return selectList("findCertificates", enterpriseId); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/persistence/EntepriseDao.java b/src/main/java/com/dreawer/shopcenter/persistence/EntepriseDao.java new file mode 100644 index 0000000..327582b --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/persistence/EntepriseDao.java @@ -0,0 +1,81 @@ +package com.dreawer.shopcenter.persistence; + +import com.dreawer.dream.persistence.mybatis.MyBatisBaseDao; +import com.dreawer.retail.domain.Enterprise; +import org.springframework.stereotype.Repository; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.dreawer.retail.DAOConstants.ENTERPRISE_DAO; +import static com.dreawer.retail.DomainConstants.ID; +import static com.dreawer.retail.DomainConstants.TYPE; + +@Repository(ENTERPRISE_DAO) +public class EntepriseDao extends MyBatisBaseDao { + + /** + * 保存企业信息。 + * @param enterprise 企业信息。 + * @return + */ + public int save(Enterprise enterprise){ + return insert("save", enterprise); + } + + /** + * 更新企业基本信息。 + * @param enterprise 企业信息。 + * @return + */ + public int updateBasic(Enterprise enterprise){ + return update("updateBasic", enterprise); + } + + /** + * 查询企业信息。 + * @param type 查询类型 + * @return + */ + public Enterprise findEnterprise(String appid, String id, String type){ + Map params = new HashMap<>(); + params.put("appid", appid); + params.put(TYPE, type); + params.put(ID, id); + return selectOne("findEnterprise", params); + } + + /** + * 通过名称查询企业信息。 + * @param name 企业名称 + * @return + */ + public Enterprise findEnterpriseByName(String name) { + return selectOne("findEnterpriseByName", name); + } + + /** + * 查询所有企业id + * @return + */ + public List findAllEnterpriseId() { + return this.getSqlSession().selectList("findAllEnterpriseId"); + } + + /** + * 更改企业商品类目信息 + * @param enterprise + */ + public int updateMerchanCategories(Enterprise enterprise) { + return update("updateMerhcandiseCategory",enterprise); + } + + public void updateMemberRegisterPort(Map map) { + update("updateMemberRegisterPort",map); + } + + public Map findBootByAppid(String appid) { + return selectOne("findBootByAppid",appid); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/service/AddressService.java b/src/main/java/com/dreawer/shopcenter/service/AddressService.java new file mode 100644 index 0000000..38341a6 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/service/AddressService.java @@ -0,0 +1,81 @@ +package com.dreawer.shopcenter.service; + +import com.dreawer.retail.domain.Address; +import com.dreawer.retail.persistence.AddressDao; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +import static com.dreawer.retail.DAOConstants.ADDRESS_DAO; +import static com.dreawer.retail.ServiceConstants.ADDRESS_SERVICE; + +/** + * AddressService + * + * @author fenrir + * @Date 17-12-25 + */ + +@Service(ADDRESS_SERVICE) +public class AddressService { + + @Resource(name = ADDRESS_DAO) + private AddressDao addressDao; + + /** + * 查询地址数量 + * @return + */ + public Integer getCountByStoreId(String storeId) { + return addressDao.getCountByStoreId(storeId); + } + + /** + * 添加一条地址 + * @param address + */ + public void addAddress(Address address) { + addressDao.addAddress(address); + } + + /** + * 根据id查询地址 + * @param id 地址ID + */ + public Address findAddressById(String id) { + return addressDao.findAddressById(id); + } + + /** + * 修改一条地址 + * @param address + */ + public void editAddress(Address address) { + addressDao.updateAddress(address); + } + + /** + * 删除一条记录 + * @param address + */ + public void removeAddress(Address address) { + addressDao.removeAddress(address); + } + + /** + * 通过id更新默认地址 + * @param address + */ + public void updateDefaultAddress(Address address) { + addressDao.updateDefaultAddress(address); + } + + /** + * 查询所有地址信息 + * @return + */ + public List
findAllAddressByStoreId(String storeId) { + return addressDao.findAllAddressByStoreId(storeId); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/service/BusinessLicenseService.java b/src/main/java/com/dreawer/shopcenter/service/BusinessLicenseService.java new file mode 100644 index 0000000..6ed4e4c --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/service/BusinessLicenseService.java @@ -0,0 +1,52 @@ +package com.dreawer.shopcenter.service; + + +import com.dreawer.retail.domain.BusinessLicense; +import com.dreawer.retail.persistence.BusinessLicenseDao; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +import static com.dreawer.retail.DAOConstants.BUSINESS_LICENSE_DAO; +import static com.dreawer.retail.ServiceConstants.BUSSINESS_LICENCE_SERVICE; + +@Service(BUSSINESS_LICENCE_SERVICE) +public class BusinessLicenseService { + + @Resource(name= BUSINESS_LICENSE_DAO) + private BusinessLicenseDao businessLicenseDao; //营业执照dao + + /** + * 查找营业执照。 + * @param storeId 店铺id。 + * @return 证件信息 + */ + public BusinessLicense findbusinessLicense(String storeId) { + return businessLicenseDao.findBusinessLicense(storeId); + } + + /** + * 修改营业执照。 + * @param businessLicense 营业执照信息。 + */ + public void updateBusinessLicense(BusinessLicense businessLicense) { + businessLicenseDao.updateBusinessLicense(businessLicense); + } + + /** + * 添加营业执照。 + * @param businessLicense 营业执照信息。 + */ + public void addBusinessLicense(BusinessLicense businessLicense) { + businessLicenseDao.addBusinessLicense(businessLicense); + } + + /** + * 通过id查询营业执照。 + * @param id 执照id。 + * @return + */ + public BusinessLicense findBusinessLicenseById(String id) { + return businessLicenseDao.findBusinessLicenseById(id); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/service/CertificateService.java b/src/main/java/com/dreawer/shopcenter/service/CertificateService.java new file mode 100644 index 0000000..23cdb36 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/service/CertificateService.java @@ -0,0 +1,40 @@ +package com.dreawer.shopcenter.service; + +import com.dreawer.retail.domain.Certificate; +import com.dreawer.retail.persistence.CertificateDao; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +import static com.dreawer.retail.DAOConstants.CERTIFICATE_DAO; +import static com.dreawer.retail.ServiceConstants.CERTIFICATE_SERVICE; + +@Service(CERTIFICATE_SERVICE) +public class CertificateService { + + @Resource(name = CERTIFICATE_DAO) + private CertificateDao certificateDao; + + /** + * 查找其他证件信息。 + * @param storeId 店铺id + * @param type 证件类型 + * @return 证件信息 + */ + public Certificate findCertificateById(String id) { + return certificateDao.findCertificateById(id); + } + + public void updateCertificate(Certificate certificate) { + certificateDao.updateCertificate(certificate); + } + + public void addCertificate(Certificate certificate) { + certificateDao.addCertificate(certificate); + } + + public List findCertificates(String enterpriseId) { + return certificateDao.findCertificates(enterpriseId); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/service/EnterpriseService.java b/src/main/java/com/dreawer/shopcenter/service/EnterpriseService.java new file mode 100644 index 0000000..dcb4808 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/service/EnterpriseService.java @@ -0,0 +1,102 @@ +package com.dreawer.shopcenter.service; + +import com.dreawer.retail.domain.Enterprise; +import com.dreawer.retail.persistence.EntepriseDao; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.dreawer.retail.DAOConstants.ENTERPRISE_DAO; +import static com.dreawer.retail.ServiceConstants.ENTERPRISE_SERVICE; + +@Service(ENTERPRISE_SERVICE) +public class EnterpriseService { + + @Resource(name=ENTERPRISE_DAO) + private EntepriseDao entepriseDao; // 企业信息DAO + + /** + * 保存企业信息。 + * @param enterprise 企业信息。 + * @return + */ + public void save(Enterprise enterprise) { + entepriseDao.save(enterprise); + + } + + /** + * 通过id查询企业信息。 + * @param id 企业id。 + * @return + */ + public Enterprise findEnterpriseById(String id) { + return entepriseDao.findEnterprise(null, id, "id"); + } + + /** + * 通过app查询企业信息。 + * @return + */ + public Enterprise findEnterpriseByApp(String appid) { + return entepriseDao.findEnterprise(appid, null, "app"); + } + + /** + * 更新企业基本信息。 + * @param enterprise 企业信息。 + * @return + */ + public void updateBasic(Enterprise enterprise) { + entepriseDao.updateBasic(enterprise); + } + + /** + * 通过名称查询企业信息。 + * @param name 企业名称 + * @return + */ + public Enterprise findEnterpriseByName(String name) { + return entepriseDao.findEnterpriseByName(name); + } + + /** + * 查询所有企业id + * @return + */ + public List findAllEnterpriseId(){ + return entepriseDao.findAllEnterpriseId(); + } + + /** + * 更改企业商品类目信息 + * @param enterprise + */ + public void updateMerchanCategories(Enterprise enterprise) { + entepriseDao.updateMerchanCategories(enterprise); + } + + /** + * 是否在商品详情显示会员注册通道 + * @param storeId + * @param type + */ + public void updateMemberRegisterPort(String storeId, Boolean type) { + Map map = new HashMap<>(); + map.put("id",storeId); + map.put("type",type); + entepriseDao.updateMemberRegisterPort(map); + } + + /** + * 通过appid获取开屏海报 + * @param appid + * @return + */ + public Map findBootByAppid(String appid) { + return entepriseDao.findBootByAppid(appid); + } +} diff --git a/src/main/java/com/dreawer/shopcenter/web/AddressController.java b/src/main/java/com/dreawer/shopcenter/web/AddressController.java new file mode 100644 index 0000000..c3ce832 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/web/AddressController.java @@ -0,0 +1,246 @@ +package com.dreawer.shopcenter.web; + +import com.dreawer.dream.view.JSONResponse; +import com.dreawer.retail.domain.Address; +import com.dreawer.retail.form.AddAddressForm; +import com.dreawer.retail.form.EditAddressForm; +import com.dreawer.retail.service.AddressService; +import com.dreawer.user.domain.User; +import org.apache.log4j.Logger; +import org.springframework.stereotype.Controller; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.dreawer.order.MessageConstants.MSG_NOT_ADMIN; +import static com.dreawer.retail.ControllerConstants.*; +import static com.dreawer.retail.DomainConstants.*; +import static com.dreawer.retail.MessageConstants.*; +import static com.dreawer.retail.ServiceConstants.ADDRESS_SERVICE; +import static com.dreawer.retail.ViewConstants.USER; + +/** + * AddressController + * 地址控制器 + * + * @author fenrir + * @Date 17-12-25 + */ +@Controller(ADDRESS_CONTROLLER) +@RequestMapping(REQ_ADDRESS) +public class AddressController extends BaseController { + + @Resource(name = ADDRESS_SERVICE) + private AddressService addressService; + + private Logger logger = Logger.getLogger(this.getClass()); // 日志记录器 + + /** + * 添加一条地址 + * @param req 用户请求 + * @param form 表单数据 + * @return 返回结果 + */ + @RequestMapping(value = REQ_ADD,method = RequestMethod.POST) + public @ResponseBody + JSONResponse add(HttpServletRequest req, @RequestBody @Valid AddAddressForm form, BindingResult result) { + try { + User user = getSignInUser(req); + // 校验是否是店铺管理员 + if(!isAppAdmin(req, form.getStoreId())){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + if (result.hasErrors()) { + return new JSONResponse(false, getErrors(result)); + } + Address address = new Address(); + address.setAddress(form.getAddress()); + address.setStoreId(form.getStoreId()); + address.setConsignee(form.getConsignee()); + address.setContact(form.getContact()); + address.setPostcode(form.getPostcode()); + address.setShippingAddress(form.getShippingAddress()); + address.setIsDefault(false); + Integer count = addressService.getCountByStoreId(form.getStoreId()); + //如果没有新建过地址则设置为默认 + if (count == 0) { + address.setIsDefault(true); + } + address.setCreater(user); + address.setCreateTime(getNow()); + addressService.addAddress(address); + Map viewObjects = new HashMap(); + viewObjects.put(ADDRESS, address); + viewObjects.put(USER, user); + return new JSONResponse(true, viewObjects); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 修改地址 + * @param req 用户请求 + * @param form 表单数据 + * @return 返回结果 + */ + @RequestMapping(value = REQ_EDIT,method = RequestMethod.POST) + public @ResponseBody + JSONResponse edit(HttpServletRequest req,@RequestBody @Valid EditAddressForm form, BindingResult result) { + try { + User user = getSignInUser(req); + // 校验是否是店铺管理员 + if(!isAppAdmin(req, form.getStoreId())){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + if (result.hasErrors()) { + return new JSONResponse(false, getErrors(result)); + } + Address address = addressService.findAddressById(form.getId()); + if (address==null){ + return new JSONResponse(false,new Error(MSG_ADDRESS_NOTFOUND)); + } + address.setAddress(form.getAddress()); + address.setConsignee(form.getConsignee()); + address.setContact(form.getContact()); + address.setPostcode(form.getPostcode()); + address.setShippingAddress(form.getShippingAddress()); + address.setUpdater(user); + address.setUpdateTime(getNow()); + addressService.editAddress(address); + Map viewObjects = new HashMap(); + viewObjects.put(ADDRESS, address); + viewObjects.put(USER, user); + return new JSONResponse(true, viewObjects); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 删除一条地址 + * @param req + * @param id + * @return + */ + @RequestMapping(value = REQ_DELETE,method = RequestMethod.GET) + public @ResponseBody JSONResponse delete(HttpServletRequest req, @RequestParam(ID) String id, @RequestParam(STORE_ID)String storeId){ + try { + // 校验是否是店铺管理员 + if(!isAppAdmin(req, storeId)){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + Address address = addressService.findAddressById(id); + if (address==null){ + return new JSONResponse(false,new Error(MSG_ADDRESS_NOTFOUND)); + } + Integer count = addressService.getCountByStoreId(storeId); + if (count==1){ + return new JSONResponse(false,new Error(MSG_ADDRESS_DELETE_ERROR)); + } + addressService.removeAddress(address); + return new JSONResponse(true); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 修改当前地址为默认并设置其他id为非默认 + * @param req + * @return + */ + @RequestMapping(value = REQ_SET_DEFAULT,method = RequestMethod.GET) + public @ResponseBody JSONResponse setDefault(HttpServletRequest req, @RequestParam(value = ID,required = true)String id, @RequestParam(STORE_ID)String storeId){ + try { + // 校验是否是店铺管理员 + if(!isAppAdmin(req, storeId)){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + Address address = addressService.findAddressById(id); + if (address==null){ + return new JSONResponse(false,new Error(MSG_ADDRESS_NOTFOUND)); + } + addressService.updateDefaultAddress(address); + return new JSONResponse(true); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 查询当前用户所有地址信息 + * @param req + * @return + */ + @RequestMapping(value = REQ_VIEW,method = RequestMethod.GET) + public @ResponseBody JSONResponse view(HttpServletRequest req,@RequestParam(STORE_ID)String storeId){ + try { + // 校验是否是店铺管理员 + if(!isAppAdmin(req, storeId)){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + List
list = addressService.findAllAddressByStoreId(storeId); + return new JSONResponse(true,list); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 根据id查询一条地址 + * @param req + * @param id + * @return + */ + @RequestMapping(value = REQ_ONE,method = RequestMethod.GET) + public @ResponseBody JSONResponse findOne(HttpServletRequest req, @RequestParam(ID)String id, @RequestParam(STORE_ID)String storeId){ + try { + // 校验是否是店铺管理员 + if(!isAppAdmin(req, storeId)){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + Address address = addressService.findAddressById(id); + if (address==null){ + return new JSONResponse(false,new Error(MSG_ADDRESS_NOTFOUND)); + } + return new JSONResponse(true,address); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } +} diff --git a/src/main/java/com/dreawer/shopcenter/web/BaseController.java b/src/main/java/com/dreawer/shopcenter/web/BaseController.java new file mode 100644 index 0000000..d8368d5 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/web/BaseController.java @@ -0,0 +1,360 @@ +package com.dreawer.shopcenter.web; + +import com.dreawer.dream.util.MessageSourceUtils; +import com.dreawer.retail.exception.WxAppException; +import com.dreawer.retail.utils.HttpClientUtil; +import com.dreawer.user.utils.ParameterizedTypeImpl; +import com.google.gson.Gson; +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.ParseException; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import javax.servlet.http.HttpServletRequest; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.sql.Timestamp; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.dreawer.dream.util.commons.StringUtils.isBlank; +import static com.dreawer.dream.util.commons.StringUtils.stringArray2String; +import static com.dreawer.retail.ControllerConstants.APP_DETAIL; +import static com.dreawer.retail.ControllerConstants.REFRESH_TOKEN; + +/** + * BaseController 它是本系统中所有控制器的基类,提供控制器通用方法的实现。 + * @author David Dai + * @since Dreawer 1.0 + * @version 1.0 + */ +public class BaseController extends com.dreawer.user.controller.BaseController { + + // -------------------------------------------------------------------------------- + // 其他 + // -------------------------------------------------------------------------------- + + protected static final String HTTP_ACCOUNT_QUERY = MessageSourceUtils.getMessage("requestUrl", "account_query"); + + protected static final String HTTP_LATEST_AUDIT_STATUS = MessageSourceUtils.getMessage("wxAppRequest", "latest_auditstatus_query"); + + protected static final String HTTP_WXAPP_CATEGORY_QUERY = MessageSourceUtils.getMessage("wxAppRequest", "wxAppCategory_query"); + + /** + * 将指定(带空格的)关键词以 % 链接为关键词字符串。 + * @param keywords 关键词数组。 + * @return 关键词字符串。 + * @author David Dai + * @since 2.0 + */ + protected String getKeyword(String keywords) { + if (StringUtils.isBlank(keywords)) { + return keywords; + } + return keywords.replace(" ", "%"); + } + + /** + * 将指定关键词数组以 % 链接为关键词字符串。 + * @param keywords 关键词数组。 + * @return 关键词字符串。 + * @author David Dai + * @since 2.0 + */ + protected String getKeyword(String[] keywords) { + return stringArray2String(keywords, "%"); + } + + /** + * 获取当前系统时间。 + * @return 当前系统时间。 + * @author David Dai + * @since 2.0 + */ + protected Timestamp getNow() { + return new Timestamp(System.currentTimeMillis()); + } + + /** + * 将json转换成对象集合。 + * @param json json对象 + * @param clazz 对象类型 + * @return 对象集合。 + * @author Kael + * @since 2.0 + */ + protected List jsonToArray(String json, Class clazz){ + if ((StringUtils.isBlank(json)) || (clazz == null)) { + return null; + } + Type listType = new ParameterizedTypeImpl(List.class, new Class[] { clazz }); + List list = new ArrayList<>(); + list = new Gson().fromJson(json, listType); + return list; + } + + /** + * 获取request中的json参数。 + * @param req + * @return + * @throws IOException + */ + protected String getRequestJson(HttpServletRequest req) throws IOException { + StringBuilder sb = new StringBuilder(); + BufferedReader in = req.getReader(); + String line; + while ((line = in.readLine()) != null) { + sb.append(line); + } + return sb.toString(); + } + + /** + * http的post请求。 + * @param url 请求的地址。 + * @param params 请求的参数。 + * @return 返回结果。 + */ + protected String httpPost(String url, Map params) { + String result = null; + RequestConfig config = RequestConfig.custom() + .setSocketTimeout(10000) + .setConnectTimeout(10000) + .setConnectionRequestTimeout(10000) + .build(); + // 创建默认的httpClient实例. + CloseableHttpClient httpclient = HttpClients.createDefault(); + // 创建httppost + HttpPost httppost = new HttpPost(url); + httppost.setConfig(config); + // 创建参数队列 + List formparams = new ArrayList(); + //遍历参数 + for(String key : params.keySet()){ + formparams.add(new BasicNameValuePair(key, params.get(key))); + } + try { + UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(formparams, "UTF-8"); + httppost.setEntity(uefEntity); + CloseableHttpResponse response = httpclient.execute(httppost); + try { + if(response.getStatusLine().getStatusCode()==200){ + HttpEntity entity = response.getEntity(); + if (entity != null) { + result = EntityUtils.toString(entity, "UTF-8"); + } + } + } finally { + response.close(); + } + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (UnsupportedEncodingException e1) { + e1.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + // 关闭连接,释放资源 + try { + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + } + + /** + * http的get请求。 + * @param url 请求地址。 + * @param query 请求参数。 + */ + protected String httpGet(String url, String query) { + String result = null; + RequestConfig config = RequestConfig.custom() + .setSocketTimeout(10000) + .setConnectTimeout(10000) + .setConnectionRequestTimeout(10000) + .build(); + CloseableHttpClient httpclient = HttpClients.createDefault(); + try { + // 创建httpget. + HttpGet httpget = new HttpGet(url +"?"+ query); + httpget.setConfig(config); + // 执行get请求. + CloseableHttpResponse response = httpclient.execute(httpget); + try { + if(response.getStatusLine().getStatusCode()==200){ + // 获取响应实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + result = EntityUtils.toString(entity); + } + } + } finally { + response.close(); + } + } catch (ClientProtocolException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + // 关闭连接,释放资源 + try { + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + } + + // @Test + public String encrypt(String sSrc) throws Exception { + // String sSrc = "060101012D1A683D48271A18316E471A"; + String sKey = "3A60432A5C01211F291E0F4E0C132825"; + + // byte[] raw = sKey.getBytes("utf-8"); + byte[] databytes = parseHexStr2Byte(sSrc); + byte[] keybytes = parseHexStr2Byte(sKey); + SecretKeySpec skeySpec = new SecretKeySpec(keybytes, "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");//"算法/模式/补码方式" + cipher.init(Cipher.ENCRYPT_MODE, skeySpec); + byte[] encrypted = cipher.doFinal(databytes); + // String result = new Base64().encodeToString(encrypted); + return parseByte2HexStr(encrypted);//此处使用BASE64做转码功能,同时能起到2次加密的作用。 + // System.out.print(result); + } + + //@Test + public String decode(String text) throws Exception { + // String text = "EC72214CB09CD11B52FE73E901D8DC48"; + // String text = "D23331C277810CDBD096AF26DFF12D6D"; + String sKey = "3A60432A5C01211F291E0F4E0C132825"; + + byte[] databytes = parseHexStr2Byte(text); + byte[] key = parseHexStr2Byte(sKey); + + SecretKeySpec sKeySpec = new SecretKeySpec(key, "AES"); + Cipher cipher = Cipher.getInstance("AES/ECB/NoPadding");//"算法/模式/补码方式" + cipher.init(Cipher.DECRYPT_MODE, sKeySpec); + byte[] data = cipher.doFinal(databytes); + // String result = new Base64().encodeToString(data); + return parseByte2HexStr(data);//此处使用BASE64做转码功能,同时能起到2次加密的作用。 + // System.out.print(result); + } + + private static String parseByte2HexStr(byte buf[]) { + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < buf.length; i++) { + String hex = Integer.toHexString(buf[i] & 0xFF); + if (hex.length() == 1) { + hex = '0' + hex; + } + sb.append(hex.toUpperCase()); + } + return sb.toString(); + } + + private static byte[] parseHexStr2Byte(String hexStr) { + if (hexStr.length() < 1) + return null; + byte[] result = new byte[hexStr.length()/2]; + for (int i = 0;i< hexStr.length()/2; i++) { + int high = Integer.parseInt(hexStr.substring(i*2, i*2+1), 16); + int low = Integer.parseInt(hexStr.substring(i*2+1, i*2+2), 16); + result[i] = (byte) (high * 16 + low); + } + return result; + } + + /** + * 检查AccessToken是否已经过期 + * @param appId 小程序Appid + * @return 当前可用的Token + * @throws WxAppException + */ + public String checkTokenAvailability(String appId) throws WxAppException, JSONException { + Map param = new HashMap<>(); + param.put("appid", appId); + String accountResponse = HttpClientUtil.doGet(HTTP_ACCOUNT_QUERY + APP_DETAIL, param); + if (accountResponse.isEmpty()) { + throw new WxAppException("account系统异常!"); + } + JSONObject json = new JSONObject(accountResponse); + //判断返回结果 + if (!json.has("status") || !json.getBoolean("status")) { + throw new WxAppException("appId无效!"); + } + JSONObject data = json.getJSONObject("data"); + String accessToken = data.getString("accessToken"); + String response = HttpClientUtil.doGet(HTTP_LATEST_AUDIT_STATUS + "?access_token=" + accessToken); + if (response.isEmpty()) { + throw new WxAppException("系统异常,请稍后再试!"); + } + JSONObject auditResp = new JSONObject(response); + if (auditResp.getInt("errcode") == 42001 || auditResp.getInt("errcode") == 40001) { + //token过期,重新刷新token + String tokenResponse = HttpClientUtil.doGet(HTTP_ACCOUNT_QUERY + REFRESH_TOKEN + "?appid=" + appId); + if (tokenResponse.isEmpty()) { + throw new WxAppException("Token刷新失败"); + } + JSONObject tokenJson = new JSONObject(tokenResponse); + if (tokenJson.get("status").equals(false)) { + throw new WxAppException("Token刷新失败"); + } + if (tokenJson.get("status").equals(true)) { + accessToken = tokenJson.get("data").toString(); + } + } + return accessToken; + } + + /** + * 获取授权小程序帐号的可选类目 (请确保accessToken已刷新) + * + * @param accessToken + * @return jsonArray + */ + protected JSONArray getCategory(String accessToken) throws JSONException, WxAppException { + String response = HttpClientUtil.doGet(HTTP_WXAPP_CATEGORY_QUERY + "?access_token=" + accessToken); + JSONObject jsonObject = new JSONObject(response); + if (!jsonObject.has("errcode") || jsonObject.get("errcode").equals(-1)) { + throw new WxAppException("微信类目系统异常"); + } + if (jsonObject.has("errcode") && jsonObject.get("errcode").equals(48001)) { + throw new WxAppException("48001", "用户未提供权限信息"); + } + if (jsonObject.get("errcode").equals(41000)) { + //token超时 + throw new WxAppException("微信类目系统异常"); + } + //其他错误 + if (!jsonObject.get("errcode").equals(0)) { + throw new WxAppException(jsonObject.get("errmsg").toString()); + } + JSONArray category_list = jsonObject.getJSONArray("category_list"); + return category_list; + } +} diff --git a/src/main/java/com/dreawer/shopcenter/web/EnterpriseController.java b/src/main/java/com/dreawer/shopcenter/web/EnterpriseController.java new file mode 100644 index 0000000..11e25d6 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/web/EnterpriseController.java @@ -0,0 +1,612 @@ +package com.dreawer.shopcenter.web; + +import com.dreawer.dream.view.JSONResponse; +import com.dreawer.retail.domain.BusinessLicense; +import com.dreawer.retail.domain.Certificate; +import com.dreawer.retail.domain.Enterprise; +import com.dreawer.retail.exception.WxAppException; +import com.dreawer.retail.form.*; +import com.dreawer.retail.service.BusinessLicenseService; +import com.dreawer.retail.service.CertificateService; +import com.dreawer.retail.service.EnterpriseService; +import com.dreawer.user.domain.User; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.json.JSONArray; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.stereotype.Controller; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.sql.Timestamp; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import static com.dreawer.retail.ControllerConstants.ENTERPRISE_CONTROLLER; +import static com.dreawer.retail.MessageConstants.*; +import static com.dreawer.retail.ServiceConstants.*; + +@Controller(ENTERPRISE_CONTROLLER) +@RequestMapping("/enterprise") +public class EnterpriseController extends BaseController{ + + @Resource(name=ENTERPRISE_SERVICE) + private EnterpriseService enterpriseService; // 企业信息服务 + + @Resource(name=BUSSINESS_LICENCE_SERVICE) + private BusinessLicenseService businessLicenseService; // 媒体信息服务 + + @Resource(name=CERTIFICATE_SERVICE) + private CertificateService certificateService; // 媒体信息服务 + + private Logger logger = Logger.getLogger(this.getClass()); // 日志记录器 + + + /** + * 添加企业信息。 + * @param req 用户请求。 + * @param form 添加信息表单。 + * @param result 表单校验结果。 + * @return 执行结果。 + */ + @RequestMapping(value="/add", method=RequestMethod.POST) + public @ResponseBody JSONResponse add(HttpServletRequest req, + @RequestBody @Valid AddEnterpriseForm form, BindingResult result) { + if (result.hasErrors()) { + return new JSONResponse(false, getErrors(result)); + } + try { + User user = getSignInUser(req); + String appid = getApp(form.getAppid()); + if(StringUtils.isBlank(appid)){ + return new JSONResponse(false, new Error(MSG_APP_NULL)); + } + Enterprise enterprise = enterpriseService.findEnterpriseById(appid); + if(enterprise!=null){ + return new JSONResponse(false, new Error(MSG_ENTERPRISE_EXISTS)); + } + Enterprise enterpriseByApp = enterpriseService.findEnterpriseByApp(form.getAppid()); + if (enterpriseByApp!=null){ + return new JSONResponse(false, new Error(MSG_ENTERPRISE_EXISTS)); + } + enterprise = enterpriseService.findEnterpriseByName(form.getName()); + if(enterprise!=null){ + return new JSONResponse(false, new Error(MSG_ENTERPRISE_NAME_EXISTS)); + } + Enterprise ep = new Enterprise(); + ep.setId(appid); + ep.setAppid(form.getAppid()); + ep.setCategory("media"); + ep.setName(form.getName()); + ep.setShortname(form.getShortname()); + ep.setLogo(form.getLogo()); + ep.setIntro(form.getIntro()); + ep.setCreater(user); + enterpriseService.save(ep); + return new JSONResponse(true); + } catch (Exception e) { + e.printStackTrace(); + logger.error(e); + return new JSONResponse(false, new Error(MSG_SYS_BUSY)); + } + } + + /** + * 修改企业信息。 + * @param req 用户请求。 + * @param form 修改企业信息表单。 + * @param result 校验表单结果。 + * @return 执行结果。 + */ + @RequestMapping(value="/edit", method=RequestMethod.POST) + public @ResponseBody JSONResponse edit(HttpServletRequest req, + @RequestBody @Valid EditEnterpriseForm form, BindingResult result) { + if (result.hasErrors()){ + return new JSONResponse(false, getErrors(result)); + } + try { + User user = getSignInUser(req); + Enterprise ep = enterpriseService.findEnterpriseById(form.getId()); + if(ep==null){ + return new JSONResponse(false, new Error(MSG_ENTERPRISE_NULL)); + } + + if(StringUtils.isNotBlank(form.getName()) && !form.getName().equals(ep.getName())){ + Enterprise enterprise = enterpriseService.findEnterpriseByName(form.getName()); + if(enterprise!=null){ + return new JSONResponse(false, new Error(MSG_ENTERPRISE_NAME_EXISTS)); + } + ep.setName(form.getName()); + } + if(StringUtils.isNotBlank(form.getShortname())){ + ep.setShortname(form.getShortname()); + } + if(StringUtils.isNotBlank(form.getLogo())){ + ep.setLogo(form.getLogo()); + } + if(StringUtils.isNotBlank(form.getIntro())){ + ep.setIntro(form.getIntro()); + } + if(StringUtils.isNotBlank(form.getCoordinate())){ + ep.setCoordinate(form.getCoordinate()); + } + if(StringUtils.isNotBlank(form.getEmail())){ + String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$"; + Pattern regex = Pattern.compile(check); + Matcher matcher = regex.matcher(form.getEmail()); + if(matcher.matches()){ + ep.setEmail(form.getEmail()); + }else{ + return new JSONResponse(false, new Error(VAL_EMAIL_WRONG)); + } + } + if(StringUtils.isNotBlank(form.getPhone()) && StringUtils.isNotBlank(form.getMobile())){ + return new JSONResponse(false, new Error(VAL_PHONE_DUMP)); + } + if(StringUtils.isNotBlank(form.getPhone())){ + String check1 = "^((0\\d{2,3}-\\d{7,8})|(1[3584]\\d{9}))$"; + Pattern regex1 = Pattern.compile(check1); + Matcher matcher1 = regex1.matcher(form.getPhone()); + String check2 = "^[48]00-[0-9]{7}"; + Pattern regex2 = Pattern.compile(check2); + Matcher matcher2 = regex2.matcher(form.getPhone()); + if(!matcher2.matches() && !matcher1.matches()){ + return new JSONResponse(false, new Error(VAL_PHONE_WRONG)); + } + ep.setPhone(form.getPhone()); + ep.setMobile(form.getMobile()); + } + if(StringUtils.isNotBlank(form.getMobile())){ + ep.setPhone(form.getPhone()); + ep.setMobile(form.getMobile()); + } + if(StringUtils.isNotBlank(form.getBootImage())){ + // 设置启动画面和启动时间 + if(null==form.getBootTime()){ + return new JSONResponse(false, new Error(MSG_BOOT_TIME_NULL)); + } + if(5 certificates = certificateService.findCertificates(enterpriseId); + return new JSONResponse(true, certificates); + }catch (Exception e){ + logger.error(e); + return new JSONResponse(false, new Error(MSG_SYS_BUSY)); + } + } + + /** + * 查询特殊证件详情。 + * @param req 用户请求。 + * @return + */ + @RequestMapping(value = "/certificate/detail", method = RequestMethod.GET) + public @ResponseBody JSONResponse certificateDetail(HttpServletRequest req){ + try { + String id = req.getParameter("id"); + if(StringUtils.isBlank(id)){ + return new JSONResponse(false, new Error(VAL_ENTERPRISE_ID_EMPTY)); + } + Certificate certificate = certificateService.findCertificateById(id); + return new JSONResponse(true, certificate); + }catch (Exception e){ + logger.error(e); + return new JSONResponse(false, new Error(MSG_SYS_BUSY)); + } + } + + /** + * 添加特殊证件信息。 + * @param req 用户请求。 + * @param form 添加证件表单。 + * @param result 表单校验结果。 + * @return + */ + @RequestMapping(value = "/addCertificate", method = RequestMethod.POST) + public @ResponseBody JSONResponse addCertificate(HttpServletRequest req, + @RequestBody @Valid AddCertificateForm form, BindingResult result){ + if(result.hasErrors()){ + return new JSONResponse(false,getErrors(result)); + } + try { + User user = getSignInUser(req); + Enterprise enterprise = enterpriseService.findEnterpriseById(form.getEnterpriseId()); + if(enterprise==null){ + return new JSONResponse(false, new Error(MSG_ENTERPRISE_NULL)); + } + Certificate certificate = new Certificate(); + certificate.setEnterpriseId(form.getEnterpriseId()); + certificate.setName(form.getName()); + certificate.setImage(form.getImage()); + certificate.setNumber(form.getNumber()); + certificate.setValidityType(form.getValidityType()); + certificate.setValidity(form.getValidity()); + certificate.setAddress(form.getAddress()); + certificate.setCreater(user); + certificateService.addCertificate(certificate); + return new JSONResponse(true); + }catch (Exception e){ + logger.error(e); + return new JSONResponse(false, new Error(MSG_SYS_BUSY)); + } + } + + /** + * 编辑其他营业证件信息。 + * @param req 用户请求 + * @author lyan + * @since 1.0 + */ + @RequestMapping(value = "/editCertificate", method = RequestMethod.POST) + public @ResponseBody JSONResponse editCertificate(HttpServletRequest req, + @RequestBody @Valid EditCertificateForm form, BindingResult result){ + if(result.hasErrors()){ + return new JSONResponse(false, getErrors(result)); + } + try { + User user = getSignInUser(req); + Certificate certificate = certificateService.findCertificateById(form.getId()); + if(certificate==null){ + return new JSONResponse(false, new Error(MSG_CERTIFICATE_NULL)); + } + certificate.setName(form.getName()); + certificate.setImage(form.getImage()); + certificate.setNumber(form.getNumber()); + certificate.setValidityType(form.getValidityType()); + certificate.setValidity(form.getValidity()); + certificate.setAddress(form.getAddress()); + certificate.setUpdater(user); + certificate.setUpdateTime(getNow()); + certificateService.updateCertificate(certificate); + return new JSONResponse(true); + }catch (Exception e){ + logger.error(e); + return new JSONResponse(false, new Error(MSG_SYS_BUSY)); + } + } + + /** + * 通过appid获取开屏海报 + * @param req + * @param appid + * @return + */ + @RequestMapping(value = "/getBoot",method = RequestMethod.GET) + public @ResponseBody JSONResponse getBoot(HttpServletRequest req,@RequestParam("appid")String appid){ + try { + Map map = enterpriseService.findBootByAppid(appid); + if (map==null){ + map= new HashMap<>(); + map.put("id",null); + map.put("bootImage",null); + map.put("bootTime",null); + } + return new JSONResponse(true,map); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 获取appid。 + * @param appid + * @return + */ + private String getApp(String appid) throws JSONException { + String result = httpGet("https://account.dreawer.com/app/detail", "appid=" + appid); + if(StringUtils.isNotBlank(result)){ + JSONObject json = new JSONObject(result); + if(json!=null && json.getBoolean("status")){ + JSONObject data = json.getJSONObject("data"); + return data.getString("id"); + } + logger.error("result="+result); + } + return null; + } + + /** + * 验证手机号。 + * @param phoneNumber 手机号。 + * @param value 验证码。 + * @return + */ + private boolean verifyPhone(String phoneNumber, String value) throws JSONException { + Map params = new HashMap<>(); + params.put("phone", phoneNumber); + params.put("captcha", value); + String result = httpPost("https://account.dreawer.com/verify/phone/commen", params); + logger.error("phone="+phoneNumber+"captcha="+value); + logger.error("result="+result); + if(StringUtils.isNotBlank(result)){ + JSONObject json = new JSONObject(result); + if(json!=null && json.getBoolean("status")){ + return true; + } + } + return false; + } + /** + * 获取小程序类目 + */ + @RequestMapping(value = "/appCategory",method = RequestMethod.GET) + public @ResponseBody JSONResponse chooseIndustry(HttpServletRequest req,@RequestParam("id") String storeId){ + try { + User user = getSignInUser(req); + isAppAdmin(req,storeId); + Enterprise enterprise = enterpriseService.findEnterpriseById(storeId); + if (enterprise==null){ + return new JSONResponse(false,new Error("未查询到该企业")); + } + String appid = enterprise.getAppid(); + if (StringUtils.isBlank(appid)){ + logger.error("企业信息错误"+enterprise.toString()); + return new JSONResponse(false,new Error("未查询到小程序appId")); + } + String token = checkTokenAvailability(appid); + JSONArray category = getCategory(token); + logger.error(category+"---------------------------------------------"); + Map map = new HashMap<>(); + map.put("category",category); + return new JSONResponse(true,map); + } catch (WxAppException e) { + logger.error(e.getErrMsg()); + return new JSONResponse(false,new Error(e.getErrMsg())); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 修改企业可用类目信息 + */ + @RequestMapping(value = "/editMerchanCategories",method = RequestMethod.POST) + public @ResponseBody JSONResponse editMerchanCategories(HttpServletRequest req,@RequestBody @Valid AddCategoryForm form,BindingResult result){ + if (result.hasErrors()) { + return new JSONResponse(false, getErrors(result)); + } + try { + String ids = form.getIds(); + String storeId = form.getStoreId(); + isAppAdmin(req,storeId); + Enterprise enterprise = enterpriseService.findEnterpriseById(storeId); + if (enterprise==null){ + return new JSONResponse(false,new Error("未查询到该企业")); + } + enterprise.setMerchanCategories(ids); + enterpriseService.updateMerchanCategories(enterprise); + return new JSONResponse(true); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + + /** + * 修改是否在商品详情显示会员注册通道 + */ + @RequestMapping(value = "/editPortStatus",method = RequestMethod.POST) + public @ResponseBody JSONResponse editMemberRegisterPort(HttpServletRequest req, @RequestBody @Valid EditMerchanCategoriesForm form, BindingResult result){ + if (result.hasErrors()) { + return new JSONResponse(false, getErrors(result)); + } + try { + Boolean type = Boolean.valueOf(form.getType()); + String storeId = form.getStoreId(); + isAppAdmin(req,storeId); + Enterprise enterprise = enterpriseService.findEnterpriseById(storeId); + if (enterprise==null){ + return new JSONResponse(false,new Error("未查询到该企业")); + } + enterpriseService.updateMemberRegisterPort(storeId,type); + return new JSONResponse(true,enterprise); + } catch (Exception e) { + String log = ERR_OTHER; + logger.error(log, e); + + // 返回失败标志及信息 + String message = MSG_SYSTEM_BUSY; + return new JSONResponse(false, new Error(message)); + } + } + +} diff --git a/src/main/java/com/dreawer/shopcenter/web/MerchantController.java b/src/main/java/com/dreawer/shopcenter/web/MerchantController.java new file mode 100644 index 0000000..23b8e57 --- /dev/null +++ b/src/main/java/com/dreawer/shopcenter/web/MerchantController.java @@ -0,0 +1,182 @@ +package com.dreawer.shopcenter.web; + +import com.dreawer.dream.view.JSONResponse; +import com.dreawer.pay.domain.Merchant; +import com.dreawer.pay.form.AddMerchantForm; +import com.dreawer.pay.form.EditMerchantForm; +import com.dreawer.pay.service.MerchantService; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import javax.validation.Valid; +import java.util.List; + +import static com.dreawer.order.MessageConstants.MSG_NOT_ADMIN; +import static com.dreawer.pay.MessageConstants.*; + +@Controller +public class MerchantController extends BaseController { + + @Autowired + private MerchantService merchantService; + + private Logger logger = Logger.getLogger(this.getClass()); // 日志记录器 + + + /** + * 添加商户信息。 + * @param req 用户请求。 + * @param form 商户信息表单。 + * @param result 表单校验结果。 + * @return + */ + @RequestMapping(value="/merchant/add", method=RequestMethod.POST) + public @ResponseBody JSONResponse add(HttpServletRequest req, + @RequestBody @Valid AddMerchantForm form, BindingResult result) { + if (result.hasErrors()) { + return new JSONResponse(false, getErrors(result)); + } + try { + // 校验类型是否存在 + if(form.getType()==null){ + return new JSONResponse(false, new Error(MSG_TYPE_ERROR)); + } + + // 校验店铺是否存在 + if(!isAppAdmin(req, form.getStoreId())){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + Merchant merchant = merchantService.findMerchantByType(form.getStoreId(), form.getType()); + if(merchant!=null){ + return new JSONResponse(false, new Error(MSG_MERCHANT_EXISTS)); + } + merchant = new Merchant(); + merchant.setStoreId(form.getStoreId()); + merchant.setAppid(form.getAppid()); + merchant.setMchid(form.getMchid()); + merchant.setKey(form.getKey()); + merchant.setCert(form.getCert()); + merchant.setType(form.getType()); + merchant.setCreater(getSignInUser(req)); + merchantService.save(merchant); + return new JSONResponse(true); + } catch (Exception e) { + e.printStackTrace(); + logger.error(e); + + // 返回失败标志及信息 + return new JSONResponse(false, new Error(MSG_SYSTEM_BUSY)); + } + } + + /** + * 修改商户信息。 + * @param req 用户请求。 + * @param form 商户信息表单。 + * @param result 表单校验结果。 + * @return + */ + @RequestMapping(value="/merchant/edit", method=RequestMethod.POST) + public @ResponseBody JSONResponse edit(HttpServletRequest req, + @RequestBody @Valid EditMerchantForm form, BindingResult result) { + if (result.hasErrors()) { + return new JSONResponse(false, getErrors(result)); + } + try { + if(form.getType()==null){ + return new JSONResponse(false, new Error(MSG_TYPE_ERROR)); + } + Merchant merchant = merchantService.findMerchantById(form.getId()); + if(merchant==null){ + return new JSONResponse(false, new Error(MSG_MERCHANT_NULL)); + } + merchant.setMchid(form.getMchid()); + merchant.setKey(form.getKey()); + merchant.setCert(form.getCert()); + merchant.setType(form.getType()); + merchantService.updateBasic(merchant); + return new JSONResponse(true); + } catch (Exception e) { + e.printStackTrace(); + logger.error(e); + + // 返回失败标志及信息 + return new JSONResponse(false, new Error(MSG_SYSTEM_BUSY)); + } + } + + /** + * 添加商户信息。 + * @param req 用户请求。 + * @return + */ + @RequestMapping(value="/merchant/delete", method=RequestMethod.GET) + public @ResponseBody JSONResponse delete(HttpServletRequest req, @RequestParam("id") String id) { + try { + Merchant merchant = merchantService.findMerchantById(id); + if(merchant==null){ + return new JSONResponse(false, new Error(MSG_MERCHANT_NULL)); + } + merchantService.delete(merchant); + return new JSONResponse(true); + } catch (Exception e) { + e.printStackTrace(); + logger.error(e); + + // 返回失败标志及信息 + return new JSONResponse(false, new Error(MSG_SYSTEM_BUSY)); + } + } + + /** + * 查询店铺的商户列表。 + * @param req 用户请求。 + * @param storeId 店铺id。 + * @return + */ + @RequestMapping(value="/merchant/list", method=RequestMethod.GET) + public @ResponseBody JSONResponse list(HttpServletRequest req, @RequestParam("storeId") String storeId) { + try { + List merchants = merchantService.findMerchantByStore(storeId); + // 校验店铺是否存在 + if(!isAppAdmin(req, storeId)){ + return new JSONResponse(false, new Error(MSG_NOT_ADMIN)); + } + return new JSONResponse(true, merchants); + } catch (Exception e) { + e.printStackTrace(); + logger.error(e); + + // 返回失败标志及信息 + return new JSONResponse(false, new Error(MSG_SYSTEM_BUSY)); + } + } + + /** + * 通过id查询商户详情。 + * @param req 用户请求。 + * @param id 商户信息id。 + * @return + */ + @RequestMapping(value="/merchant/detail", method=RequestMethod.GET) + public @ResponseBody JSONResponse detail(HttpServletRequest req, @RequestParam("id") String id) { + try { + Merchant merchant = merchantService.findMerchantById(id); + if(merchant==null){ + return new JSONResponse(false, new Error(MSG_MERCHANT_NULL)); + } + return new JSONResponse(true, merchant); + } catch (Exception e) { + e.printStackTrace(); + logger.error(e); + + // 返回失败标志及信息 + return new JSONResponse(false, new Error(MSG_SYSTEM_BUSY)); + } + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..e69de29 diff --git a/src/test/java/com/dreawer/shopcenter/ShopcenterApplicationTests.java b/src/test/java/com/dreawer/shopcenter/ShopcenterApplicationTests.java new file mode 100644 index 0000000..bb70283 --- /dev/null +++ b/src/test/java/com/dreawer/shopcenter/ShopcenterApplicationTests.java @@ -0,0 +1,16 @@ +package com.dreawer.shopcenter; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class ShopcenterApplicationTests { + + @Test + public void contextLoads() { + } + +}